|
Evo C++ Library v0.5.1
|
#include <evo/map.h>

Associative container holding key/value pairs for fast lookup.
| TKey | Map key type |
| TValue | Map value type |
| TSize | Size type to use for size values (must be unsigned integer) – default: SizeT |
Caution: Modifying or resizing a map will shift or invalidate existing iterators using it.
Maps that use a hash/comparison type will have these additional methods (not included in this interface), where T is the hash/compare type used:
const T& get_compare() constT& get_compare()See MapList or MapHash for example.
Ordered maps will have these additional methods (not included in this interface):
Iter iter_lower(const Key& value) constIter iter_upper(const Key& value) constIterM iter_lowerM(const Key& value)IterM iter_upperM(const Key& value)Size remove(const Value& Key, Size count)Size remove_range(IterM& Key, Size count)Size remove_range(IterM& Key, IterM& end)See MapList for example.
List maps will have these additional methods (not included in this interface):
Size item(Size index) constSize removeat(Size index)See MapList for example.
Classes | |
| struct | InitPair |
| Initializer key/value pair, used with initializer (C++11). More... | |
Public Types | |
| typedef void | EvoContainerType |
| typedef Pair< Key, Value > | Item |
| Item type (key/value pair) More... | |
| typedef IteratorBi< ThisType >::Const | Iter |
| Iterator (const) - IteratorBi. More... | |
| typedef IteratorBi< ThisType > | IterM |
| Iterator (mutable) - IteratorBi. More... | |
| typedef TKey | Key |
| Key type. More... | |
| using | KeyPass = typename DataCopy< TKey >::PassType |
| Key type for passing through InitPair (C++11) More... | |
| typedef Map< TKey, TValue, TSize > | MapBaseType |
| Map base type More... | |
| typedef TSize | Size |
| Size type for size values (must be unsigned integer) – default: SizeT. More... | |
| typedef Map< TKey, TValue, TSize > | ThisType |
| This type. More... | |
| typedef TValue | Value |
| Value type. More... | |
| using | ValuePass = typename DataCopy< TValue >::PassType |
| Value type for passing through InitPair (C++11) More... | |
Public Member Functions | |
| virtual | ~Map () |
| Destructor. More... | |
| virtual Item & | add (const Key &key, const Value &value, bool update=true)=0 |
| Add or update using given key and value. More... | |
| virtual Item & | add (const Item &item, bool update=true)=0 |
| Add or update using given item. More... | |
| virtual MapBaseType & | add (const MapBaseType &map, bool update=true)=0 |
| Add items from given map. More... | |
| template<class T > | |
| Size | addsplit (const T &str, char delim=',', char kvdelim='=') |
| Split delimited string into map key/value items. More... | |
| const MapBaseType & | asconst () const |
| Explicitly use a const reference to this. More... | |
| IterM | begin () |
| Get iterator at first item (mutable). More... | |
| Iter | begin () const |
| Get iterator at first item (const). More... | |
| virtual Size | capacity () const =0 |
| Get map capacity. More... | |
| virtual MapBaseType & | capacity (Size size)=0 |
| Set map capacity. More... | |
| virtual MapBaseType & | capacitymin (Size min)=0 |
| Set map capacity to at least given minimum. More... | |
| Iter | cbegin () const |
| Get iterator at first item (const). More... | |
| Iter | cend () const |
| Get iterator at end (const). More... | |
| virtual MapBaseType & | clear ()=0 |
| Clear by removing all items. More... | |
| virtual MapBaseType & | compact () |
| Reduce capacity to fit current size (modifier). More... | |
| virtual bool | contains (const Key &key) const =0 |
| Get whether map contains the given key. More... | |
| bool | empty () const |
| Get whether map is empty (size is 0). More... | |
| IterM | end () |
| Get iterator at end. More... | |
| Iter | end () const |
| Get iterator at end (const). More... | |
| virtual const Value * | find (const Key &key) const =0 |
| Find (lookup) value for given key (const). More... | |
| virtual Value * | findM (const Key &key)=0 |
| Find (lookup) value for given key (mutable). More... | |
| Value & | get (const Key &key, bool *created=NULL) |
| Get item value for key (mutable). More... | |
| virtual Item & | getitem (const Key &key, bool *created=NULL)=0 |
| Get map item for key (mutable). More... | |
| Iter | iter (const Key &key) const |
| Find (lookup) iterator for given key (const). More... | |
| IterM | iterM (const Key &key) |
| Find (lookup) iterator for given key (mutable). More... | |
| virtual bool | null () const =0 |
| Get whether map is null. More... | |
| bool | operator!= (const MapBaseType &map) const |
| Inequality operator. More... | |
| MapBaseType & | operator= (const MapBaseType &src) |
| Assignment operator. More... | |
| bool | operator== (const MapBaseType &map) const |
| Equality operator. More... | |
| Value & | operator[] (const Key &key) |
| Get item value for key (mutable). More... | |
| bool | ordered () const |
| Get whether map is ordered. More... | |
| virtual bool | remove (const Key &key)=0 |
| Find and remove item with given key. More... | |
| virtual bool | remove (IterM &iter, IteratorDir dir=iterNONE)=0 |
| Remove item using given iterator. More... | |
| MapBaseType & | reserve (Size size) |
| Reserve space for new items. More... | |
| virtual MapBaseType & | set ()=0 |
| Set as null and empty. More... | |
| virtual MapBaseType & | set (const MapBaseType &src)=0 |
| Set as copy of given map. More... | |
| virtual MapBaseType & | setempty ()=0 |
| Set as empty but not null. More... | |
| virtual bool | shared () const =0 |
| Get whether shared. More... | |
| Size | size () const |
| Get map size (number of items). More... | |
| virtual MapBaseType & | unshare ()=0 |
| Make data unique by allocating new buffer, if needed (modifier). More... | |
Protected Member Functions | |
| Map () | |
| Constructor. More... | |
| Map (bool ordered) | |
| Constructor. More... | |
| Map (const Map &)=delete | |
| Copy constructor (disabled). More... | |
| virtual const Item * | getiter (IterKey &iterkey, const Key &key) const =0 |
| Used by base class to get data to initialize iterator. More... | |
Protected Attributes | |
| bool | ordered_ |
| Whether map is ordered (items are kept in order by key) More... | |
| Size | size_ |
| Map size (number of items, automatically updated by concrete set members) More... | |
| typedef void EvoContainerType |
| typedef IteratorBi<ThisType>::Const Iter |
Iterator (const) - IteratorBi.
| typedef IteratorBi<ThisType> IterM |
Iterator (mutable) - IteratorBi.
| typedef TKey Key |
Key type.
| typedef Map<TKey,TValue,TSize> MapBaseType |
Map base type
| typedef TSize Size |
Size type for size values (must be unsigned integer) – default: SizeT.
| typedef TValue Value |
Value type.
Value type for passing through InitPair (C++11)
|
inlineprotected |
Constructor.
Used by derived types.
|
inlineprotected |
Constructor.
Used by derived types.
| ordered | Whether map is ordered |
|
inlinevirtual |
Destructor.
Add or update using given key and value.
| key | Key to find/add (copied) |
| value | Value to add/update (copied) |
| update | Whether to update value for existing item |
Implemented in MapHash< TKey, TValue, THash, TSize >, MapList< TKey, TValue, TCompare, TSize >, MapList< String, CommandInfo >, MapList< SigNumType, Handler >, and MapList< String, OptionInfoShPtr >.
Add or update using given item.
| item | Item to use for add/update (copied) |
| update | Whether to update value for existing item |
Implemented in MapHash< TKey, TValue, THash, TSize >, MapList< TKey, TValue, TCompare, TSize >, MapList< String, CommandInfo >, MapList< SigNumType, Handler >, and MapList< String, OptionInfoShPtr >.
|
pure virtual |
Add items from given map.
| map | Map to add items from |
| update | Whether to update value for existing items |
Implemented in MapList< TKey, TValue, TCompare, TSize >, MapList< String, CommandInfo >, MapList< SigNumType, Handler >, and MapList< String, OptionInfoShPtr >.
|
inline |
Split delimited string into map key/value items.
| T | String type to parse – inferred from str parameter |
| str | String to parse |
| delim | Item delimiter to use |
| kvdelim | Key/Value delimiter to use |
|
inline |
Explicitly use a const reference to this.
|
inline |
|
inline |
Get iterator at first item (const).
|
pure virtual |
Get map capacity.
Implemented in MapList< TKey, TValue, TCompare, TSize >, MapList< String, CommandInfo >, MapList< SigNumType, Handler >, MapList< String, OptionInfoShPtr >, and MapHash< TKey, TValue, THash, TSize >.
|
pure virtual |
Set map capacity.
| size | New capacity |
Implemented in MapHash< TKey, TValue, THash, TSize >, MapList< TKey, TValue, TCompare, TSize >, MapList< String, CommandInfo >, MapList< SigNumType, Handler >, and MapList< String, OptionInfoShPtr >.
|
pure virtual |
Set map capacity to at least given minimum.
| min | Minimum capacity |
Implemented in MapHash< TKey, TValue, THash, TSize >, MapList< TKey, TValue, TCompare, TSize >, MapList< String, CommandInfo >, MapList< SigNumType, Handler >, and MapList< String, OptionInfoShPtr >.
|
inline |
|
inline |
|
pure virtual |
Clear by removing all items.
Implemented in MapList< TKey, TValue, TCompare, TSize >, MapList< String, CommandInfo >, MapList< SigNumType, Handler >, MapList< String, OptionInfoShPtr >, and MapHash< TKey, TValue, THash, TSize >.
|
inlinevirtual |
Reduce capacity to fit current size (modifier).
Reimplemented in MapList< TKey, TValue, TCompare, TSize >, MapList< String, CommandInfo >, MapList< SigNumType, Handler >, and MapList< String, OptionInfoShPtr >.
|
pure virtual |
Get whether map contains the given key.
| key | Key to look for |
Implemented in MapList< TKey, TValue, TCompare, TSize >, MapList< String, CommandInfo >, MapList< SigNumType, Handler >, MapList< String, OptionInfoShPtr >, and MapHash< TKey, TValue, THash, TSize >.
|
inline |
Get whether map is empty (size is 0).
|
inline |
|
inline |
Get iterator at end (const).
Find (lookup) value for given key (const).
| key | Key to find |
Implemented in MapList< TKey, TValue, TCompare, TSize >, MapList< String, CommandInfo >, MapList< SigNumType, Handler >, MapList< String, OptionInfoShPtr >, and MapHash< TKey, TValue, THash, TSize >.
Find (lookup) value for given key (mutable).
| key | Key to find |
Implemented in MapList< TKey, TValue, TCompare, TSize >, MapList< String, CommandInfo >, MapList< SigNumType, Handler >, MapList< String, OptionInfoShPtr >, and MapHash< TKey, TValue, THash, TSize >.
Get item value for key (mutable).
| key | Key to use |
| created | Stores whether new item was created, if not NULL |
Get map item for key (mutable).
| key | Key to use |
| created | Stores whether new item was created, if not NULL |
Implemented in MapList< TKey, TValue, TCompare, TSize >, MapList< String, CommandInfo >, MapList< SigNumType, Handler >, MapList< String, OptionInfoShPtr >, and MapHash< TKey, TValue, THash, TSize >.
Used by base class to get data to initialize iterator.
| iterkey | Set to iterator data, if item found |
| key | Key to find |
Implemented in MapHash< TKey, TValue, THash, TSize >, MapList< TKey, TValue, TCompare, TSize >, MapList< String, CommandInfo >, MapList< SigNumType, Handler >, and MapList< String, OptionInfoShPtr >.
Find (lookup) iterator for given key (const).
| key | Key to find |
Find (lookup) iterator for given key (mutable).
| key | Key to find |
|
pure virtual |
Get whether map is null.
Implemented in MapList< TKey, TValue, TCompare, TSize >, MapList< String, CommandInfo >, MapList< SigNumType, Handler >, MapList< String, OptionInfoShPtr >, and MapHash< TKey, TValue, THash, TSize >.
|
inline |
Inequality operator.
| map | Map to compre |
|
inline |
Assignment operator.
| src | Source to copy |
|
inline |
Equality operator.
| map | Map to compre |
Get item value for key (mutable).
| key | Key to use |
|
inline |
Get whether map is ordered.
|
pure virtual |
Find and remove item with given key.
| key | Key to use |
Implemented in MapHash< TKey, TValue, THash, TSize >, MapList< TKey, TValue, TCompare, TSize >, MapList< String, CommandInfo >, MapList< SigNumType, Handler >, and MapList< String, OptionInfoShPtr >.
|
pure virtual |
Remove item using given iterator.
| iter | Iterator position |
| dir | Direction to move iterator to next item, iterNONE for end position |
Implemented in MapHash< TKey, TValue, THash, TSize >, MapHash< TKey, TValue, THash, TSize >, MapList< TKey, TValue, TCompare, TSize >, MapList< String, CommandInfo >, MapList< SigNumType, Handler >, MapList< String, OptionInfoShPtr >, MapList< TKey, TValue, TCompare, TSize >, MapList< String, CommandInfo >, MapList< SigNumType, Handler >, and MapList< String, OptionInfoShPtr >.
|
inline |
Reserve space for new items.
| size | Size to reserve |
|
pure virtual |
Set as null and empty.
Implemented in MapList< TKey, TValue, TCompare, TSize >, MapList< String, CommandInfo >, MapList< SigNumType, Handler >, MapList< String, OptionInfoShPtr >, and MapHash< TKey, TValue, THash, TSize >.
|
pure virtual |
Set as copy of given map.
| src | Source map |
Implemented in MapList< TKey, TValue, TCompare, TSize >, MapList< String, CommandInfo >, MapList< SigNumType, Handler >, MapList< String, OptionInfoShPtr >, MapList< TKey, TValue, TCompare, TSize >, MapList< String, CommandInfo >, MapList< SigNumType, Handler >, MapList< String, OptionInfoShPtr >, and MapHash< TKey, TValue, THash, TSize >.
|
pure virtual |
Set as empty but not null.
Implemented in MapList< TKey, TValue, TCompare, TSize >, MapList< String, CommandInfo >, MapList< SigNumType, Handler >, MapList< String, OptionInfoShPtr >, and MapHash< TKey, TValue, THash, TSize >.
|
pure virtual |
Get whether shared.
Implemented in MapList< TKey, TValue, TCompare, TSize >, MapList< String, CommandInfo >, MapList< SigNumType, Handler >, MapList< String, OptionInfoShPtr >, and MapHash< TKey, TValue, THash, TSize >.
|
pure virtual |
Make data unique by allocating new buffer, if needed (modifier).
Implemented in MapHash< TKey, TValue, THash, TSize >, MapList< TKey, TValue, TCompare, TSize >, MapList< String, CommandInfo >, MapList< SigNumType, Handler >, and MapList< String, OptionInfoShPtr >.
|
protected |
Whether map is ordered (items are kept in order by key)
|
protected |
Map size (number of items, automatically updated by concrete set members)
1.8.13