Overview
Examples
Screenshots
Comparisons
Applications
Download
Manual
Status & Roadmap
FAQ
Authors & License
Forums
Wiki
Funding Ultimate++
Search on this site











SourceForge.net Logo



Algorithms

 

Global Functions


 

template <class T> void Swap(T& a, T& b)

Swaps values. Specific types might specialize Swap with more effective variants.

T must have either deep copy operator or pick operator.

T

Type of values.

a

First value to swap.

b

Second value to swap.

 


 

template <class I> void IterSwap(I a, I b)

Swaps values pointed to by iterators. Specific types might specialize IterSwap with more effective variants.

Swap must be defined for type pointed to by I.

I

Iterator type.

a

Iterator pointing to first value.

b

Iterator pointing to second value.

 


 

template <class C, class T, class L> int FindLowerBound(const C& v, int pos, int count, const T& val, const L& less)

Finds first position in range of container sorted by less predicate where val can be inserted without breaking the ordering.

C

Type of container.

T

Type of value.

v

Container.

pos

Beginning of range.

count

Number of elements in range.

val

Value to find.

less

Ordering predicate.

Return value

Position in container.

 


 

template <class C, class T, class L> int FindLowerBound(const C& v, const T& val, const L& less)

Finds first position in sorted by less predicate where val can be inserted without breaking the ordering.

C

Type of container.

T

Type of value.

v

Container.

val

Value to find.

less

Ordering predicate.

Return value

Position in container.

 


 

template <class C, class T> int FindLowerBound(const C& v, const T& val)

Finds first position in sorted by operator< predicate where val can be inserted without breaking the ordering.

C

Type of container.

T

Type of value.

v

Container.

val

Value to find.

Return value

Position in container.

 


 

template <class C, class T, class L> int FindUpperBound(const C& v, int pos, int count, const T& val, const L& less)

Finds last position in range of container sorted by less predicate where val can be inserted without breaking the ordering.

C

Type of container.

T

Type of value.

v

Container.

pos

Beginning of range.

count

Number of elements in range.

val

Value to find.

less

Ordering predicate.

Return value

Position in container.

 


 

template <class C, class T, class L> int FindUpperBound(const C& v, const T& val, const L& less)

Finds last position in sorted by less predicate where val can be inserted without breaking the ordering.

C

Type of container.

T

Type of value.

v

Container.

val

Value to find.

less

Ordering predicate.

Return value

Position in container.

 


 

template <class C, class T> int FindUpperBound(const C& v, const T& val)

Finds last position in sorted by operator< predicate where val can be inserted without breaking the ordering.

C

Type of container.

T

Type of value.

v

Container.

val

Value to find.

Return value

Position in container.

 


 

template <class C, class T, class L> int FindBinary(const C& v, const T& val, int pos, int count, const L& less)

Finds position of element with specified value in a range of container sorted by less predicate. If no such element exists, a negative value is returned.

C

Type of container.

T

Type of value.

v

Container.

pos

Beginning of range.

count

Number of elements in range.

val

Value to find.

less

Ordering predicate.

Return value

Position in container.

 


 

template <class C, class T, class L> int FindBinary(const C& v, const T& val, const L& less)

Finds position of element with specified value in the container sorted by less predicate. If no such element exists, a negative value is returned.

C

Type of container.

T

Type of value.

v

Container.

val

Value to find.

less

Ordering predicate.

Return value

Position in container.

 


 

template <class C, class T> int FindBinary(const C& v, const T& val)

Finds position of element with specified value in the container sorted by operator< predicate. If no such element exists, a negative value is returned.

C

Type of container.

T

Type of value.

v

Container.

val

Value to find.

Return value

Position in container.

 


 

template <class C, class L> C& AppendSorted(C& dest, const C& src, const L& less)

Merges source NTL container to destination NTL container. Both containers must be sorted in ascending order. After the operation, destination container is sorted in ascending order and contains values from both containers. Duplicate values are preserved. Ordering predicate is determined by less.

C

Type of container.

dest

Destination container.

src

Source container.

less

Ordering predicate.

Return value

Destination container.template<class C>

 


 

template <class C> C& AppendSorted(C& dest, const C& src)

Merges source NTL container to destination NTL container. Both containers must be sorted in ascending order. After the operation, destination container is sorted in ascending order and contains values from both containers. Duplicate values are preserved. Ordering is determined by operator<.

C

Type of container.

dest

Destination container.

src

Source container.

Return value

Destination container.template<class C>

 


 

template <class C, class L> C& UnionSorted(C& dest, const C& src, const L& less)

Merges source NTL container to destination NTL container. Both containers must be sorted in ascending order and values must be unique. After the operation, destination container is sorted in ascending order and contains unique values from both containers. Ordering is determined by less.

C

Type of container.

dest

Destination container.

src

Source container.

less

Ordering predicate.

Return value

Destination container.

 


 

template <class C> C& UnionSorted(C& dest, const C& src)

Merges the source NTL container to the destination NTL container. Both containers must be sorted in ascending order and values must be unique. After the operation, destination container is sorted in ascending order and contains unique values from both containers. Ordering is determined by operator<.

C

Type of container.

dest

Destination container.

src

Source container.

Return value

Destination container.

 


 

template <class C, class L> C& RemoveSorted(C& from, const C& what, const L& less)

Removes elements of source container from destination container. Both containers must be sorted in ascending order and values must be unique. Ordering is determined by less.

C

Type of container.

from

Destination container.

what

Source container.

less

Ordering predicate.

Return value

Destination container.

 


 

template <class C> C& RemoveSorted(C& from, const C& what)

Removes elements of source container from destination container. Both containers must be sorted in ascending order and values must be unique. Ordering is determined by operator<.

C

Type of container.

from

Destination container.

what

Source container.

Return value

Destination container.

 


 

template <class D, class S, class L> D& IntersectSorted(D& dest, const S& src, const L& less)

Removes elements from destination container that are not contained in source container. Both containers must be sorted in ascending order and values must be unique. Ordering is determined by less.

D

Type of destination container.

S

Type of source container.

dest

Destination container.

src

Source container.

less

Destination container.

 


 

template <class D, class S> D& IntersectSorted(D& dest, const S& src)

Removes elements from destination container that are not contained in source container. Both containers must be sorted in ascending order and values must be unique. Ordering is determined by operator<.

D

Type of destination container.

S

Type of source container.

dest

Destination container.

src

Source container.

Return value

Destination container.

 


 

template <class T, class Less> void Sort(T& c, const Less& less)

Sorts container. Ordering is determined by less.

IterSwap must be defined for T::Iterator.

T

Type of container.

c

Container.

less

Ordering predicate.

 


 

template <class T> void Sort(T& c)

Sorts container. Ordering is determined by operator<.

IterSwap must be defined for T::Iterator.

T

Type of container.

c

Container.

 


 

template <class KC, class VC, class Less> void IndexSort(KC& keys, VC& values, const Less& less)

Sorts pair of containers. Both containers must have same number of items. Resulting order is determined by the keys container. Ordering is determined by less.

KC

Type of keys container.

VC

Type of values.

keys

Container of keys.

values

Container of values.

less

Ordering predicate.

 


 

template <class KC, class VC> void IndexSort(KC& keys, VC& values)

Sorts pair of containers. Both containers must have same number of items. Resulting order is determined by the keys container. Ordering is determined by operator<.

KC

Type of keys container.

VC

Type of values container.

keys

Container of keys.

values

Container of values.

 


 

template <class C, class Less> Vector<int> GetSortOrder(const C& container, const Less& less)

Creates ascending order of values in container. Ordering is determined by less.

C

Type of container.

container

Source container.

less

Ordering predicate.

Return value

Vector of positions of source container in sorted order.

 


 

template <class C> Vector<int> GetSortOrder(const C& container)

Creates ascending order of values in container. Ordering is determined by operator<.

C

Type of container.

container

Source container.

Return value

Vector of positions of source container in sorted order.

 


 

template <class O, class T, class R> FieldRelationCls<O, T, R> FieldRelation(O (T::*member), const R& relation)

Creates ordering predicate for T based on the value of member variable of T.

T

Type of element.

member

Member variable of T.

relation

Ordering relation for member.

Return value

Ordering predicate.

 


 

template <class O, class T, class R> MethodRelationCls<O (T::*)(), T, R> MethodRelation(O (T::*method)(), const R& relation)

Creates ordering predicate for T based on the value returned by non-const method of T.

T

Type of element.

method

Method of T.

relation

Ordering relation for value returned by method.

Return value

Ordering predicate.

 


 

template <class O, class T, class R> MethodRelationCls<O (T::*)() const, T, R> MethodRelation(O (T::*method)() const, const R& relation)

Creates ordering predicate for T based on the value returned by const method of T.

T

Type of element.

method

Method of T.

relation

Ordering relation for value returned by method.

Return value

Ordering predicate.