template <class K, class T, class Less, class Data>
class SortedAMap : private MoveableAndDeepCopyOption< SortedAMap<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.
int FindLowerBound(const K& k) const
Returns lower-bound index of element with key k.
int FindUpperBound(const K& k) const
Returns upper bound index of element with key k .
int Find(const K& k) const
Returns the minimum index of element with key equal to k or negative number if not found.
int FindNext(int i) const
If the key at i + 1 is equal to the key at i , returns i + 1, otherwise returns negative number.
int FindLast(const K& k) const
Returns the meximum index of element with key equal to k or negative number if not found.
int FindPrev(int i) const
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& k) const
Returns the value of the first element with key k. If not found, behaviour is undefined.
const T& Get(const K& k, const T& d) const
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& k) const
Returns to pointer to the value of the first element with key k. If not found, returns NULL.
const K& GetKey(int i) const
Returns the key of element at i.
const T& operator[](int i) const
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 pos) const
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 pos) const
Returns iterator to value at begin/end/pos.
|