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













SourceForge.net Logo

SortedAMap

 

template <class K, class T, class Less, class Data>

class SortedAMap : private MoveableAndDeepCopyOptionSortedAMap<K, T, Less, Data> > 

SortedAMap implements methods common to both SortedVectorMap and SortedArrayMap. Sorted map is composition of SortedIndex and InVector or InArray. It uses strict ordering of keys by predicate Less to binary search for element. Type of keys K is required to by moveable type. Like any other NTL container, AMap is moveable type with pick and optional deep copy transfer semantics, although these features are more important in derived concrete AMap flavors.

 

Public Method List

 

int FindLowerBound(const K& kconst

Returns lower-bound index of element with key k.

 


 

int FindUpperBound(const K& kconst

Returns upper bound index of element with key k .

 


 

int Find(const K& kconst

Returns the minimum index of element with key equal to k or negative number if not found.

 


 

int FindNext(int iconst

If the key at i + 1 is equal to the key at i , returns i + 1, otherwise returns negative number.

 


 

int FindLast(const K& kconst

Returns the meximum index of element with key equal to k or negative number if not found.

 


 

int FindPrev(int iconst

If the key at i - 1 is equal to the element at i , returns i - 1, otherwise returns negative number.

 


 

T& Get(const K& k)

const T& Get(const K& kconst

Returns the value of the first element with key k. If not found, behaviour is undefined.

 


 

const T& Get(const K& k, const T& dconst

Returns the value of the first element with key k. If not found, returns d.

 


 

T *FindPtr(const K& k)

const T *FindPtr(const K& kconst

Returns to pointer to the value of the first element with key k. If not found, returns NULL.

 


 

const K& GetKey(int iconst

Returns the key of element at i.

 


 

const T& operator[](int iconst

T& operator[](int i)

Returns the value of element at i.

 


 

int GetCount() const

Returns the number of elements.

 


 

bool IsEmpty() const

Same as GetCount() == 0.

 


 

void Clear()

Removes all elements.

 


 

void Shrink()

Minimizes the memory usage, dropping allocation reserves.

 


 

void Remove(int i)

Removes element at i.

 


 

void Remove(int i, int count)

Removes count elements at i.

 


 

int RemoveKey(const K& k)

Removes all elements with key k.

 


 

void Swap(SortedAMap& x)

Swaps this SortedAMap with another one.

 


 

bool IsPicked() const

Returns true if SortedAMap is picked.

 


 

const SortedIndex<K>& GetIndex() const

Returns a reference to the internal index of keys.

 


 

const InVector<K>& GetKeys() const

Returns a reference to the internal InVector of keys.

 


 

SortedAMap(const SortedAMap& s, int)

Deep copy constructor.

 


 

KeyConstIterator KeyBegin() const

KeyConstIterator KeyEnd() const

KeyConstIterator KeyGetIter(int posconst

Returns iterator to key at begin/end/pos.

 


 

Iterator Begin()

Iterator End()

Iterator GetIter(int pos)

ConstIterator Begin() const

ConstIterator End() const

ConstIterator GetIter(int posconst

Returns iterator to value at begin/end/pos.

 

Last edit by cxl on 03/16/2014. Do you want to contribute?. T++