template<class KeyType, class DataType, class HashFunc = StdHash<KeyType>>
class Murl::ObjectMap< KeyType, DataType, HashFunc >
A generic map template class for non-moveable objects eg. NonCopyable classes.
See MapBase class for all map methods.
A map stores a number of key/value pairs, where the keys do not have to be unique.
The object map class uses pointers to the value objects, this ensures that the object's memory location is unchanged when modifying the map.
This class is based on the NTL ArrayMap container, see http://www.ultimatepp.org
- Template Parameters
-
KeyType | The key's data type of the map. |
DataType | The value's data type of the map. |
HashFunc | The hash function of the key. |
|
| ObjectMap () |
| The default constructor. More...
|
|
| ObjectMap (const ObjectMap &map) |
| The copy constructor. More...
|
|
DataType & | Add (const KeyType &key, DataType *value) |
| Add a key/value pair to the map. More...
|
|
DataType & | Insert (SInt32 index, const KeyType &key, DataType *value) |
| Insert a key/value pair into the map at a given position. More...
|
|
template<class DataTypeT > |
DataTypeT & | Create (const KeyType &key) |
| Create and add an value at the specified key. More...
|
|
DataType & | Set (SInt32 index, DataType *item) |
| Set a new allocated value item at a given position. More...
|
|
DataType * | PopDetach () |
| Removes the item from the top position and giving up ownership. More...
|
|
DataType * | Detach (SInt32 index) |
| Removes the item at a given position and giving up ownership. More...
|
|
DataType * | Swap (SInt32 index, DataType *newItem) |
| Swap the item at a given position with a new allocated item. More...
|
|
void | Clear () |
| Clear the map and remove the underlying storage.
|
|
void | Empty () |
| Empty the map, but keep the underlying storage.
|
|
void | Shrink () |
| Shrink the map so that the underlying key and value storage is only as large as necessary.
|
|
void | Trim (SInt32 n) |
| Reduce the map to a given number of items. More...
|
|
void | Drop (SInt32 n=1) |
| Reduce the map by removing a given number of items from the end. More...
|
|
void | Reserve (SInt32 n) |
| Reserve storage space. More...
|
|
void | Sweep () |
| Remove any unlinked pairs from the map.
|
|
void | SetKey (SInt32 index, const KeyType &key) |
| Set the key of a given index. More...
|
|
void | Swap (MapBase &other) |
| Exchange the content of the map with a given second one. More...
|
|
DataType & | Add (const KeyType &key) |
| Add a new key/value pair to the map. More...
|
|
DataType & | Add (const KeyType &key, const DataType &value) |
| Add a key/value pair to the map. More...
|
|
DataType & | Put (const KeyType &key) |
| Add a new key/value pair to the map, replacing an unlinked element if present. More...
|
|
SInt32 | Put (const KeyType &key, const DataType &value) |
| Add a key/value pair to the map, replacing an unlinked element if present. More...
|
|
DataType & | Insert (SInt32 index, const KeyType &key) |
| Insert a new key/value pair into the map at a given position. More...
|
|
DataType & | Insert (SInt32 index, const KeyType &key, const DataType &value) |
| Insert a key/value pair into the map at a given position. More...
|
|
void | Unlink (SInt32 index) |
| Unlink the pair at a given index. More...
|
|
SInt32 | UnlinkKey (const KeyType &key) |
| Unlink all pairs matching a given key. More...
|
|
SInt32 | UnlinkKey (const KeyType &key, UInt32 hash) |
| Unlink all pairs matching a given key, using a precomputed hash value. More...
|
|
Bool | IsUnlinked (SInt32 index) const |
| Check if the pair at a given index is unlinked. More...
|
|
void | Remove (SInt32 index) |
| Remove the key/value pair at a given position from the map. More...
|
|
void | Remove (SInt32 index, SInt32 count) |
| Remove a number of key/value pairs from the map at a given starting position. More...
|
|
void | Remove (const SInt32 *sortedIndices, SInt32 count) |
| Remove a number of key/value pairs from the map at given positions. More...
|
|
void | Remove (const SInt32Array &sortedIndices) |
| Remove a number of key/value pairs from the map at given positions. More...
|
|
SInt32 | RemoveKey (const KeyType &key) |
| Remove all pairs from the map that match a given key. More...
|
|
SInt32 | Find (const KeyType &key) const |
| Find the first occurrence of a given key in the map. More...
|
|
SInt32 | Find (const KeyType &key, UInt32 hash) const |
| Find the first occurrence of a given key in the map, using a precomputed hash value. More...
|
|
SInt32 | FindLast (const KeyType &key) const |
| Find the last occurrence of a given key in the map. More...
|
|
SInt32 | FindLast (const KeyType &key, UInt32 hash) const |
| Find the last occurrence of a given key in the map, using a precomputed hash value. More...
|
|
SInt32 | FindNext (SInt32 index) const |
| Find the next occurrence of a key that is specified by a given index. More...
|
|
SInt32 | FindPrev (SInt32 index) const |
| Find the previous occurrence of a key that is specified by a given index. More...
|
|
SInt32 | FindAdd (const KeyType &key) |
| Find the first occurrence of a given key in the map, or add a new pair if the key was not found. More...
|
|
SInt32 | FindAdd (const KeyType &key, const DataType &value) |
| Find the first occurrence of a given key in the map, or add a new pair if the key was not found. More...
|
|
SInt32 | FindPut (const KeyType &key) |
| Find the first occurrence of a given key in the map, or add a new pair if the key was not found, hereby replacing an unlinked element if possible. More...
|
|
SInt32 | FindPut (const KeyType &key, const DataType &value) |
| Find the first occurrence of a given key in the map, or add a new pair if the key was not found, hereby replacing an unlinked element if possible. More...
|
|
DataType & | Get (const KeyType &key) |
| Get a reference to the first occurrence of a given key in the map. More...
|
|
const DataType & | Get (const KeyType &key) const |
| Get a const reference to the first occurrence of a given key in the map. More...
|
|
const DataType & | Get (const KeyType &key, const DataType &defaultValue) const |
| Get a const reference to the first occurrence of a given key in the map. More...
|
|
DataType * | GetPtr (const KeyType &key) |
| Get a pointer to the first occurrence of a given key in the map. More...
|
|
const DataType * | GetPtr (const KeyType &key) const |
| Get a const pointer to the first occurrence of a given key in the map. More...
|
|
DataType & | GetAdd (const KeyType &key) |
| Get a reference to the first occurrence of a given key in the map, or add a new pair if the key was not found. More...
|
|
DataType & | GetAdd (const KeyType &key, const DataType &value) |
| Get a reference to the first occurrence of a given key in the map, or add a new pair if the key was not found. More...
|
|
DataType & | GetPut (const KeyType &key) |
| Get a reference to the first occurrence of a given key in the map, or add a new pair if the key was not found, hereby replacing an unlinked element if possible. More...
|
|
DataType & | GetPut (const KeyType &key, const DataType &value) |
| Get a reference to the first occurrence of a given key in the map, or add a new pair if the key was not found, hereby replacing an unlinked element if possible. More...
|
|
const KeyType & | GetKey (SInt32 index) const |
| Get a const reference to the key at a given index. More...
|
|
const KeyIndexType & | GetIndex () const |
| Get a const reference to the key storage. More...
|
|
const Array< KeyType > & | GetKeys () const |
| Get a const reference to the array of keys. More...
|
|
ObjectArray< DataType > & | GetValues () |
| Get a reference to the array of values. More...
|
|
const ObjectArray< DataType > & | GetValues () const |
| Get a const reference to the array of values. More...
|
|
Bool | IsIndexValid (SInt32 index) const |
| Check if a given index is a valid index. More...
|
|
const DataType & | operator[] (SInt32 index) const |
| Get a const reference to the value at a given index. More...
|
|
DataType & | operator[] (SInt32 index) |
| Get a reference to the value at a given index. More...
|
|
DataType & | Bottom () |
| Get a reference to the first value in the storage. More...
|
|
const DataType & | Bottom () const |
| Get a const reference to the first value in the storage. More...
|
|
const KeyType & | BottomKey () const |
| Get a const reference to the first key in the storage. More...
|
|
DataType & | Top () |
| Get a reference to the last value in the storage. More...
|
|
const DataType & | Top () const |
| Get a const reference to the last value in the storage. More...
|
|
const KeyType & | TopKey () const |
| Get a const reference to the last key in the storage. More...
|
|
KeyType | PopKey () |
| Remove the last key/value pair from the map and return its key. More...
|
|
SInt32 | GetAlloc () const |
| Get the number of actually allocated pairs. More...
|
|
SInt32 | GetCount () const |
| Get the number of items in the map. More...
|
|
Bool | IsEmpty () const |
| Check if the map is empty. More...
|
|
KeyConstIterator | KeyBegin () const |
| Get the const key iterator to the first element. More...
|
|
KeyConstIterator | KeyEnd () const |
| Get the const key iterator next to the last element. More...
|
|
KeyConstIterator | KeyGetIter (SInt32 index) const |
| Get the const key iterator of a specified index. More...
|
|
ConstIterator | Begin () const |
| Get the const iterator to the first element. More...
|
|
Iterator | Begin () |
| Get the iterator to the first element. More...
|
|
ConstIterator | End () const |
| Get the const iterator next to the last element. More...
|
|
Iterator | End () |
| Get the iterator next to the last element. More...
|
|
ConstIterator | GetIter (SInt32 index) const |
| Get the const iterator of a specified index. More...
|
|
Iterator | GetIter (SInt32 index) |
| Get the iterator of a specified index. More...
|
|
Bool | IsEqual (const MapBase &other) const |
| Compare the map to another one. More...
|
|
bool | operator== (const MapBase &rhs) const |
| The "equal to" comparison operator, calls IsEqual(). More...
|
|
bool | operator!= (const MapBase &rhs) const |
| The "not equal to" comparison operator, calls IsEqual(). More...
|
|