template <class K, class T, class Less = StdLess<K> >
class SortedArrayMap : public MoveableAndDeepCopyOption<SortedArrayMap<K, T, Less> >, public SortedAMap<K, T, Less, Slaved_InArray__<T> >
Vector flavor of SortedAMap. It has default pick transfer semantics with optional deep-copy. It is Moveable. Keys have to be Moveable but there is no general restriction on values, they can even be derived from T.
T& Add(const K& k, const T& x)
T& Add(const K& k, T&& x)
Inserts a copy of key-value pair at upper bound key position and returns reference to element value.
T& Add(const K& k)
Inserts the key at upper bound key position and returns reference to the default constructed value at the same index.
T& Add(const K& k, T *newt)
Inserts the key at upper bound key position and sets key to newt - SortedArrayMap takes ownership. Returns *newt.
template <class TT, class... Args> TT& Create(const K& k, Args&&... args)
Inserts the key at upper bound key position and creates a new value of type TT using args as constructor parameters. TT has to be derived from T. Returns a reference to this newly created value.
int FindAdd(const K& k)
If key k is present, returns index of its lower-bound position. If not, inserts it at upper-bound position and returns its index (value of element is default-constructed).
int FindAdd(const K& k, const T& init)
If key k is present, returns index of its lower-bound position. If not, inserts it at upper-bound position with value of element copy-constructed from init and returns its index.
T& GetAdd(const K& k)
If key k is present, returns reference of value at its lower-bound position. If not, inserts it at upper-bound position and returns reference to coresponding value (value of element is default-constructed).
T& GetAdd(const K& k, const T& x)
If key k is present, returns reference of value at its lower-bound position. If not, inserts it at upper-bound position and returns reference to coresponding value, which is copy-constructed from x.
T *Detach(int i)
Removes element at i and returns the pointer to value. This pointer should be deleted by client code.
SortedArrayMap& operator()(const K& k, const T& v)
Same as Add(k, v), returns *this. Syntax sugar for creating map.
SortedArrayMap(const SortedArrayMap& s, int)
Deep copy constructor.
SortedArrayMap(std::initializer_list<std::pair<K, T>> init)
C++ 11 initialization.
|