template<typename K, typename V, Bool SORTED = true, typename COMPARE = DefaultCompare, typename ARRAY = BaseArraySelector<>>
class maxon::ArrayMap< K, V, SORTED, COMPARE, ARRAY >
An ArrayMap maps keys to values using an underlying array whose elements are key-value-pairs. It may be either sorted or unsorted. For very small maps, unsorted array maps are generally faster. For large maps (exceeding about 100 entries), you should consider using another implementation such as HashMap or BurstTrieMap because especially insertion and erasure become slow with array maps: For a sorted ArrayMap, those operations have a time cost of O(N), while searching has a time cost of O(log N).
Of all maps, the ArrayMap is the most efficient with respect to memory usage as it really only stores the key-value-pairs.
See HashMap for more examples on how to use maps in general.
- Template Parameters
-
K | Type of keys. |
V | Type of values. |
SORTED | Use true for a sorted array. |
COMPARE | Class to be used to compare the keys. |
ARRAY | An array selector template to choose the array implementation to use. |
- See also
- $ref maps
|
using | IsArrayMap = std::true_type |
|
using | ArrayType = typename ArrayMapHelper< K, V, SORTED, COMPARE, ARRAY >::Array |
|
using | Super = MapBase< ArrayMap< K, V, SORTED, COMPARE, ARRAY >, K, V, ArrayType, COMPARE > |
|
using | Entry = Pair< K, V > |
|
using | IteratorBase = AutoIterator< const ArrayType > |
|
using | Iterator = IteratorTemplate< false, EntryIteratorBase > |
|
using | ConstIterator = IteratorTemplate< true, EntryIteratorBase > |
|
using | KeyIterator = IteratorTemplate< false, KeyIteratorBase > |
|
using | ConstKeyIterator = IteratorTemplate< true, KeyIteratorBase > |
|
using | ValueIterator = IteratorTemplate< false, ValueIteratorBase > |
|
using | ConstValueIterator = IteratorTemplate< true, ValueIteratorBase > |
|
using | MapType = ArrayMap< K, V, true, DefaultCompare, BaseArraySelector<> > |
|
using | Super = BaseCollection< ArrayMap< K, V, true, DefaultCompare, BaseArraySelector<> >, ArrayMapHelper< K, V, true, DefaultCompare, BaseArraySelector<> >::Array > |
|
using | KeyType = K |
|
using | ValueType = V |
|
using | IsCollection = std::true_type |
|
|
Iterator | Begin () |
|
Iterator | End () |
|
ConstIterator | Begin () const |
|
ConstIterator | End () const |
|
KeyIterator | GetKeys () |
|
ConstKeyIterator | GetKeys () const |
|
ValueIterator | GetValues () |
|
ConstValueIterator | GetValues () const |
|
| ArrayMap () |
|
| ArrayMap (ArrayMap &&src) |
|
| MAXON_OPERATOR_MOVE_ASSIGNMENT (ArrayMap) |
|
template<typename MAP , typename CMP > |
SFINAEHelper< Bool, typename MAP::IsArrayMap, typename MAP::IsSorted, typename std::enable_if< STD_IS_REPLACEMENT(same, typename std::decay< CMP >::type, DefaultCompare)>::type >::type | IsEqualImpl (const MAP &b, CMP &&cmp, OverloadRank1) const |
|
Int | GetOperationCountForSearch () const |
|
ResultRef< V > | InsertKey (const K &key, Bool &created=BoolLValue()) |
|
ResultRef< V > | InsertKey (K &&key, Bool &created=BoolLValue()) |
|
ResultMemT< Iterator > | InsertEntry (const K &key, Bool &created=BoolLValue()) |
|
ResultMemT< Iterator > | InsertEntry (K &&key, Bool &created=BoolLValue()) |
|
ResultMemT< Iterator > | Insert (const K &key, const V &value, Bool &created=BoolLValue()) |
|
ResultMemT< Iterator > | Insert (K &&key, const V &value, Bool &created=BoolLValue()) |
|
ResultMemT< Iterator > | Insert (const K &key, V &&value, Bool &created=BoolLValue()) |
|
ResultMemT< Iterator > | Insert (K &&key, V &&value, Bool &created=BoolLValue()) |
|
template<typename KEYCOMPARE = COMPARE, typename KEY > |
const V * | FindValue (const KEY &key) const |
|
template<typename KEYCOMPARE = COMPARE, typename KEY > |
V * | FindValue (const KEY &key) |
|
Iterator | Find (const K &key) |
|
ConstIterator | Find (const K &key) const |
|
Iterator | FindFloor (const K &key) |
|
ConstIterator | FindFloor (const K &key) const |
|
Iterator | FindCeiling (const K &key) |
|
ConstIterator | FindCeiling (const K &key) const |
|
ResultOk< Bool > | Erase (const K &key) |
|
template<template< Bool > class SUPER> |
IteratorTemplate< false, SUPER > | Erase (const IteratorTemplate< false, SUPER > &position, Int eraseCnt=1) |
|
const ArrayType & | GetUnderlyingArray () const |
|
ArrayType & | GetUnderlyingArray () |
|
MAXON_ATTRIBUTE_FORCE_INLINE | MapBase (ARGS &&... args) |
|
MapImpl< ArrayMap< K, V, true, DefaultCompare, BaseArraySelector<> > & > | ToMap () |
|
MapImpl< const ArrayMap< K, V, true, DefaultCompare, BaseArraySelector<> > & > | ToMap () const |
|
MAXON_ATTRIBUTE_FORCE_INLINE | operator MapImpl< ArrayMap< K, V, true, DefaultCompare, BaseArraySelector<> > & > () |
|
MAXON_ATTRIBUTE_FORCE_INLINE | operator MapImpl< const ArrayMap< K, V, true, DefaultCompare, BaseArraySelector<> > & > () const |
|
MAXON_ATTRIBUTE_FORCE_INLINE | MapBase0 (ARGS &&... args) |
|
MAXON_ATTRIBUTE_FORCE_INLINE Bool | Contains (typename ByValueParam< K >::type key) const |
|
MAXON_ATTRIBUTE_FORCE_INLINE SFINAEHelper< Bool, typename PAIR::KeyType >::type | Contains (const PAIR &pair) const |
|
ResultRef< V > | Append (const K &key) |
|
SFINAEHelper< ResultRef< V >, typename PAIR::KeyType >::type | Append (const PAIR &pair) |
|
Result< void > | Add (COLLECTION2 &&other, COLLECTION_RESIZE_FLAGS resizeFlags=COLLECTION_RESIZE_FLAGS::ON_GROW_RESERVE_CAPACITY) |
|
Result< void > | AppendAll (COLLECTION2 &&other, COLLECTION_RESIZE_FLAGS resizeFlags=COLLECTION_RESIZE_FLAGS::ON_GROW_RESERVE_CAPACITY) |
|
Result< void > | AppendAllInverse (COLLECTION2 &&other) |
|
Bool | ContainsAllImpl (COLLECTION2 &&other, OverloadRank0) const |
|
Result< void > | SubtractImpl (COLLECTION2 &&other, OverloadRank0) |
|
Bool | IsEqualImpl (const COLLECTION2 &other, COMPARE &&cmp, OverloadRank0) const |
|
HashInt | GetHashCode () const |
|
MAXON_ATTRIBUTE_FORCE_INLINE | BaseCollection (ARGS &&... args) |
|
MAXON_ATTRIBUTE_FORCE_INLINE std::enable_if< maxon::IsCollection< COLLECTION2 >::value, Bool >::type | operator== (const COLLECTION2 &other) const |
|
MAXON_ATTRIBUTE_FORCE_INLINE std::enable_if< maxon::IsCollection< COLLECTION2 >::value, Bool >::type | operator!= (const COLLECTION2 &other) const |
|
MAXON_ATTRIBUTE_FORCE_INLINE std::enable_if< maxon::IsCollection< COLLECTION2 >::value &&!STD_IS_REPLACEMENT(same, typename std::decay< COMPARE >::type, EQUALITY), Bool >::type | IsEqual (const COLLECTION2 &other, COMPARE &&cmp=COMPARE()) const |
|
MAXON_ATTRIBUTE_FORCE_INLINE Result< void > | AppendAll (COLLECTION2 &&other, COLLECTION_RESIZE_FLAGS resizeFlags=COLLECTION_RESIZE_FLAGS::ON_GROW_RESERVE_CAPACITY) |
|
MAXON_ATTRIBUTE_FORCE_INLINE Result< void > | CopyFrom (COLLECTION2 &&other, COLLECTION_RESIZE_FLAGS resizeFlags=COLLECTION_RESIZE_FLAGS::FIT_TO_SIZE) |
|
MAXON_ATTRIBUTE_FORCE_INLINE Result< void > | Subtract (COLLECTION2 &&other) |
|
MAXON_ATTRIBUTE_FORCE_INLINE Result< void > | Intersect (const COLLECTION2 &other) |
|
Bool | Intersects (const COLLECTION2 &other) const |
|
MAXON_ATTRIBUTE_FORCE_INLINE Result< void > | CopyFromImpl (COLLECTION2 &&other, COLLECTION_RESIZE_FLAGS resizeFlags, OverloadRank0) |
|
Result< void > | AppendAllImpl (COLLECTION2 &&other, COLLECTION_RESIZE_FLAGS resizeFlags, Bool overwrite, OverloadRank0) |
|
Result< void > | IntersectImpl (COLLECTION2 &&other, OverloadRank0) |
|
MAXON_ATTRIBUTE_FORCE_INLINE Bool | IsEmpty () const |
|
MAXON_ATTRIBUTE_FORCE_INLINE Bool | IsPopulated () const |
|
String | ToString (const FormatStatement *formatStatement=nullptr) const |
|
MAXON_ATTRIBUTE_FORCE_INLINE Bool | ContainsAll (COLLECTION2 &&other) const |
|
Bool | ContainsAllImpl (COLLECTION2 &&other, OverloadRank0) const |
|