Murl::MapBase< KeyType, DataType, ArrayType, HashFunc > Class Template Reference

A generic map template base class. More...

#include "murl_map_base.h"

Public Types

typedef KeyType KeyValueType
 The template key parameter value type. More...
 
typedef DataType ValueType
 The template data parameter value type. More...
 
typedef Index< KeyType, HashFunc > KeyIndexType
 Definition of the key index type.
 
typedef KeyIndexType::ConstIterator KeyConstIterator
 Definition of the const key iterator.
 
typedef ArrayType::ConstIterator ConstIterator
 Definition of the const iterator.
 
typedef ArrayType::Iterator Iterator
 Definition of the iterator.
 

Public Member Functions

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 KeyIndexTypeGetIndex () 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...
 
ArrayType & GetValues ()
 Get a reference to the array of values. More...
 
const ArrayType & 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...
 
ConstIterator End () const
 Get the const iterator next to the last element. More...
 
ConstIterator GetIter (SInt32 index) const
 Get the const iterator of a specified index. More...
 
Iterator Begin ()
 Get the iterator to the first element. More...
 
Iterator End ()
 Get the iterator next to the last element. 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...
 

Detailed Description

template<class KeyType, class DataType, class ArrayType, class HashFunc>
class Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >

A generic map template base class.

A map stores a number of key/value pairs, where the keys do not have to be unique.
This is the base class of the Map and ObjectMap class.
This class is based on the NTL AMap container, see http://www.ultimatepp.org

Template Parameters
KeyTypeThe key's data type of the map.
DataTypeThe value's data type of the map.
ArrayTypeThe array type of the values.
HashFuncThe hash function of the key.

Member Typedef Documentation

◆ KeyValueType

template<class KeyType, class DataType, class ArrayType, class HashFunc>
typedef KeyType Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::KeyValueType

The template key parameter value type.

◆ ValueType

template<class KeyType, class DataType, class ArrayType, class HashFunc>
typedef DataType Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::ValueType

The template data parameter value type.

Member Function Documentation

◆ Trim()

template<class KeyType, class DataType, class ArrayType, class HashFunc>
void Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::Trim ( SInt32  n)
inline

Reduce the map to a given number of items.

Parameters
nThe new number of items in the map, must be smaller than the current item count.

◆ Drop()

template<class KeyType, class DataType, class ArrayType, class HashFunc>
void Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::Drop ( SInt32  n = 1)
inline

Reduce the map by removing a given number of items from the end.

Parameters
nThe number of items to remove from the end.

Referenced by Murl::MapBase< Murl::String, SystemFontDescriptor *, Array< SystemFontDescriptor * >, StdHash< Murl::String > >::PopKey().

◆ Reserve()

template<class KeyType, class DataType, class ArrayType, class HashFunc>
void Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::Reserve ( SInt32  n)
inline

Reserve storage space.

If the given size is less than the actual size, nothing is done.

Parameters
nThe number of items the underlying storage should hold.

◆ SetKey()

template<class KeyType, class DataType, class ArrayType, class HashFunc>
void Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::SetKey ( SInt32  index,
const KeyType &  key 
)
inline

Set the key of a given index.

Parameters
indexThe index to replace.
keyThe new key.

◆ Swap()

template<class KeyType, class DataType, class ArrayType, class HashFunc>
void Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::Swap ( MapBase< KeyType, DataType, ArrayType, HashFunc > &  other)
inline

Exchange the content of the map with a given second one.

Parameters
otherThe second map.

◆ Add() [1/2]

template<class KeyType, class DataType, class ArrayType, class HashFunc>
DataType& Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::Add ( const KeyType &  key)
inline

Add a new key/value pair to the map.

The newly added value is initialized using the value type's default constructor.

Parameters
keyThe key under which the value can be retrieved.
Returns
A reference to the newly constructed value.

◆ Add() [2/2]

template<class KeyType, class DataType, class ArrayType, class HashFunc>
DataType& Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::Add ( const KeyType &  key,
const DataType &  value 
)
inline

Add a key/value pair to the map.

The newly added value is initialized using the given reference value's copy constructor.

Parameters
keyThe key under which the value can be retrieved.
valueThe reference value to add.
Returns
A reference to the newly constructed value.

◆ Put() [1/2]

template<class KeyType, class DataType, class ArrayType, class HashFunc>
DataType& Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::Put ( const KeyType &  key)
inline

Add a new key/value pair to the map, replacing an unlinked element if present.

The newly added value is initialized using the value type's default constructor.

Parameters
keyThe key under which the value can be retrieved.
Returns
A reference to the newly added value.

◆ Put() [2/2]

template<class KeyType, class DataType, class ArrayType, class HashFunc>
SInt32 Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::Put ( const KeyType &  key,
const DataType &  value 
)
inline

Add a key/value pair to the map, replacing an unlinked element if present.

The newly added value is initialized using the given reference value's copy constructor.

Parameters
keyThe key under which the value can be retrieved.
valueThe reference value to add.
Returns
The index of the pair in the map.

◆ Insert() [1/2]

template<class KeyType, class DataType, class ArrayType, class HashFunc>
DataType& Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::Insert ( SInt32  index,
const KeyType &  key 
)
inline

Insert a new key/value pair into the map at a given position.

The newly added value is initialized using the value type's default constructor.

Parameters
indexThe index where to insert the new pair.
keyThe key under which the value can be retrieved.
Returns
A reference to the newly constructed value.

◆ Insert() [2/2]

template<class KeyType, class DataType, class ArrayType, class HashFunc>
DataType& Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::Insert ( SInt32  index,
const KeyType &  key,
const DataType &  value 
)
inline

Insert a key/value pair into the map at a given position.

The newly added value is initialized using the given reference value's copy constructor.

Parameters
indexThe index where to insert the new pair.
keyThe key under which the value can be retrieved.
valueThe reference value to insert.
Returns
A reference to the newly constructed value.

◆ Unlink()

template<class KeyType, class DataType, class ArrayType, class HashFunc>
void Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::Unlink ( SInt32  index)
inline

Unlink the pair at a given index.

Unlinked elements remain in the map, but are ignored by any search operations.

Parameters
indexThe index of the pair to unlink.

◆ UnlinkKey() [1/2]

template<class KeyType, class DataType, class ArrayType, class HashFunc>
SInt32 Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::UnlinkKey ( const KeyType &  key)
inline

Unlink all pairs matching a given key.

Unlinked elements remain in the map, but are ignored by any search operations.

Parameters
keyThe key for which to unlink all elements.
Returns
The number of elements that were unlinked.

◆ UnlinkKey() [2/2]

template<class KeyType, class DataType, class ArrayType, class HashFunc>
SInt32 Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::UnlinkKey ( const KeyType &  key,
UInt32  hash 
)
inline

Unlink all pairs matching a given key, using a precomputed hash value.

Unlinked elements remain in the map, but are ignored by any search operations.

Parameters
keyThe key for which to unlink all elements.
hashThe precomputed hash value.
Returns
The number of elements that were unlinked.

◆ IsUnlinked()

template<class KeyType, class DataType, class ArrayType, class HashFunc>
Bool Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::IsUnlinked ( SInt32  index) const
inline

Check if the pair at a given index is unlinked.

Parameters
indexThe index of the pair to check.
Returns
true if the pair is unlinked.

◆ Remove() [1/4]

template<class KeyType, class DataType, class ArrayType, class HashFunc>
void Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::Remove ( SInt32  index)
inline

◆ Remove() [2/4]

template<class KeyType, class DataType, class ArrayType, class HashFunc>
void Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::Remove ( SInt32  index,
SInt32  count 
)
inline

Remove a number of key/value pairs from the map at a given starting position.

Parameters
indexThe zero-based index from where to remove the first pair.
countThe number of subsequent pairs to remove.

◆ Remove() [3/4]

template<class KeyType, class DataType, class ArrayType, class HashFunc>
void Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::Remove ( const SInt32 sortedIndices,
SInt32  count 
)
inline

Remove a number of key/value pairs from the map at given positions.

Parameters
sortedIndicesA pointer to sorted indices where to remove the pairs.
countThe number of pairs to remove, i.e. the number of indices.

◆ Remove() [4/4]

template<class KeyType, class DataType, class ArrayType, class HashFunc>
void Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::Remove ( const SInt32Array sortedIndices)
inline

Remove a number of key/value pairs from the map at given positions.

Parameters
sortedIndicesA sorted array of indices where to remove the items.

◆ RemoveKey()

template<class KeyType, class DataType, class ArrayType, class HashFunc>
SInt32 Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::RemoveKey ( const KeyType &  key)
inline

Remove all pairs from the map that match a given key.

Parameters
keyThe key for which to remove the pairs.
Returns
The number of pairs that were removed.

Referenced by Murl::Logic::StateMachine< StateType, HashFunc >::Unregister().

◆ Find() [1/2]

◆ Find() [2/2]

template<class KeyType, class DataType, class ArrayType, class HashFunc>
SInt32 Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::Find ( const KeyType &  key,
UInt32  hash 
) const
inline

Find the first occurrence of a given key in the map, using a precomputed hash value.

Parameters
keyThe key to search for.
hashThe precomputed hash value.
Returns
The index of the pair in the map, or -1 if not found.

◆ FindLast() [1/2]

template<class KeyType, class DataType, class ArrayType, class HashFunc>
SInt32 Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::FindLast ( const KeyType &  key) const
inline

Find the last occurrence of a given key in the map.

Parameters
keyThe key to search for.
Returns
The index of the pair in the map, or -1 if not found.

◆ FindLast() [2/2]

template<class KeyType, class DataType, class ArrayType, class HashFunc>
SInt32 Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::FindLast ( const KeyType &  key,
UInt32  hash 
) const
inline

Find the last occurrence of a given key in the map, using a precomputed hash value.

Parameters
keyThe key to search for.
hashThe precomputed hash value.
Returns
The index of the pair in the map, or -1 if not found.

◆ FindNext()

template<class KeyType, class DataType, class ArrayType, class HashFunc>
SInt32 Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::FindNext ( SInt32  index) const
inline

Find the next occurrence of a key that is specified by a given index.

Parameters
indexThe index of the pair containing the key to search for.
Returns
The index of the next pair in the map, or -1 if not found.

Referenced by Murl::MapBase< Murl::String, SystemFontDescriptor *, Array< SystemFontDescriptor * >, StdHash< Murl::String > >::RemoveKey().

◆ FindPrev()

template<class KeyType, class DataType, class ArrayType, class HashFunc>
SInt32 Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::FindPrev ( SInt32  index) const
inline

Find the previous occurrence of a key that is specified by a given index.

Parameters
indexThe index of the pair containing the key to search for.
Returns
The index of the previous pair in the map, or -1 if not found.

◆ FindAdd() [1/2]

template<class KeyType, class DataType, class ArrayType, class HashFunc>
SInt32 Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::FindAdd ( const KeyType &  key)
inline

Find the first occurrence of a given key in the map, or add a new pair if the key was not found.

If a pair needs to be added, the newly created value is initialized using the value type's default constructor.

Parameters
keyThe key to search for.
Returns
The index of the pair in the map.

Referenced by Murl::MapBase< Murl::String, SystemFontDescriptor *, Array< SystemFontDescriptor * >, StdHash< Murl::String > >::GetPut().

◆ FindAdd() [2/2]

template<class KeyType, class DataType, class ArrayType, class HashFunc>
SInt32 Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::FindAdd ( const KeyType &  key,
const DataType &  value 
)
inline

Find the first occurrence of a given key in the map, or add a new pair if the key was not found.

If a pair needs to be added, the newly created value is initialized using the given value's copy constructor.

Parameters
keyThe key to search for.
valueThe reference value to add.
Returns
The index of the pair in the map.

◆ FindPut() [1/2]

template<class KeyType, class DataType, class ArrayType, class HashFunc>
SInt32 Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::FindPut ( const KeyType &  key)
inline

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.

If a pair needs to be added, the newly created value is initialized using the value type's default constructor.

Parameters
keyThe key to search for.
Returns
The index of the pair in the map.

◆ FindPut() [2/2]

template<class KeyType, class DataType, class ArrayType, class HashFunc>
SInt32 Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::FindPut ( const KeyType &  key,
const DataType &  value 
)
inline

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.

If a pair needs to be added, the newly created value is initialized using the given value's copy constructor.

Parameters
keyThe key to search for.
valueThe reference value to add.
Returns
The index of the pair in the map.

◆ Get() [1/3]

template<class KeyType, class DataType, class ArrayType, class HashFunc>
DataType& Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::Get ( const KeyType &  key)
inline

Get a reference to the first occurrence of a given key in the map.

If the key was not found, the behaviour is undefined.

Parameters
keyThe key to search for.
Returns
A reference to the value of the first pair found.

◆ Get() [2/3]

template<class KeyType, class DataType, class ArrayType, class HashFunc>
const DataType& Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::Get ( const KeyType &  key) const
inline

Get a const reference to the first occurrence of a given key in the map.

If the key was not found, the behaviour is undefined.

Parameters
keyThe key to search for.
Returns
A const reference to the value of the first pair found.

◆ Get() [3/3]

template<class KeyType, class DataType, class ArrayType, class HashFunc>
const DataType& Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::Get ( const KeyType &  key,
const DataType &  defaultValue 
) const
inline

Get a const reference to the first occurrence of a given key in the map.

If the key was not found, the given default value is returned

Parameters
keyThe key to search for.
defaultValueThe default value to return if the key was not found.
Returns
A const reference to the value of the first pair, or the given default value.

◆ GetPtr() [1/2]

template<class KeyType, class DataType, class ArrayType, class HashFunc>
DataType* Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::GetPtr ( const KeyType &  key)
inline

Get a pointer to the first occurrence of a given key in the map.

If the key was not found, a null pointer is returned.

Parameters
keyThe key to search for.
Returns
A pointer to the value of the first pair found, or null.

◆ GetPtr() [2/2]

template<class KeyType, class DataType, class ArrayType, class HashFunc>
const DataType* Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::GetPtr ( const KeyType &  key) const
inline

Get a const pointer to the first occurrence of a given key in the map.

If the key was not found, a null pointer is returned.

Parameters
keyThe key to search for.
Returns
A const pointer to the value of the first pair found, or null.

◆ GetAdd() [1/2]

template<class KeyType, class DataType, class ArrayType, class HashFunc>
DataType& Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::GetAdd ( const KeyType &  key)
inline

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.

If a pair needs to be added, the newly created value is initialized using the value type's default constructor.

Parameters
keyThe key to search for.
Returns
A reference to the value of the first pair found.

◆ GetAdd() [2/2]

template<class KeyType, class DataType, class ArrayType, class HashFunc>
DataType& Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::GetAdd ( const KeyType &  key,
const DataType &  value 
)
inline

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.

If a pair needs to be added, the newly created value is initialized using the given value's copy constructor.

Parameters
keyThe key to search for.
valueThe reference value to add.
Returns
A reference to the value of the first pair found.

◆ GetPut() [1/2]

template<class KeyType, class DataType, class ArrayType, class HashFunc>
DataType& Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::GetPut ( const KeyType &  key)
inline

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.

If a pair needs to be added, the newly created value is initialized using the value type's default constructor.

Parameters
keyThe key to search for.
Returns
A reference to the value of the first pair found.

◆ GetPut() [2/2]

template<class KeyType, class DataType, class ArrayType, class HashFunc>
DataType& Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::GetPut ( const KeyType &  key,
const DataType &  value 
)
inline

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.

If a pair needs to be added, the newly created value is initialized using the given value's copy constructor.

Parameters
keyThe key to search for.
valueThe reference value to add.
Returns
A reference to the value of the first pair found.

◆ GetKey()

template<class KeyType, class DataType, class ArrayType, class HashFunc>
const KeyType& Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::GetKey ( SInt32  index) const
inline

Get a const reference to the key at a given index.

If the index is out of range, the behaviour is undefined.

Parameters
indexThe index of the key to retrieve.
Returns
A const reference to the requested key.

◆ GetIndex()

template<class KeyType, class DataType, class ArrayType, class HashFunc>
const KeyIndexType& Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::GetIndex ( ) const
inline

Get a const reference to the key storage.

Returns
A const reference to the underlying key storage.

◆ GetKeys()

template<class KeyType, class DataType, class ArrayType, class HashFunc>
const Array<KeyType>& Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::GetKeys ( ) const
inline

Get a const reference to the array of keys.

Returns
A const reference to the underlying key storage array.

◆ GetValues() [1/2]

template<class KeyType, class DataType, class ArrayType, class HashFunc>
ArrayType& Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::GetValues ( )
inline

Get a reference to the array of values.

Returns
A reference to the underlying value array.

◆ GetValues() [2/2]

template<class KeyType, class DataType, class ArrayType, class HashFunc>
const ArrayType& Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::GetValues ( ) const
inline

Get a const reference to the array of values.

Returns
A const reference to the underlying value array.

◆ IsIndexValid()

template<class KeyType, class DataType, class ArrayType, class HashFunc>
Bool Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::IsIndexValid ( SInt32  index) const
inline

Check if a given index is a valid index.

Parameters
indexThe index to check.
Returns
true if index >= 0 and index < GetCount().

◆ operator[]() [1/2]

template<class KeyType, class DataType, class ArrayType, class HashFunc>
const DataType& Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::operator[] ( SInt32  index) const
inline

Get a const reference to the value at a given index.

If the index is out of range, the behaviour is undefined.

Parameters
indexThe index of the value to retrieve.
Returns
A reference to the requested value.

◆ operator[]() [2/2]

template<class KeyType, class DataType, class ArrayType, class HashFunc>
DataType& Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::operator[] ( SInt32  index)
inline

Get a reference to the value at a given index.

If the index is out of range, the behaviour is undefined.

Parameters
indexThe index of the value to retrieve.
Returns
A const reference to the requested value.

◆ Bottom() [1/2]

template<class KeyType, class DataType, class ArrayType, class HashFunc>
DataType& Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::Bottom ( )
inline

Get a reference to the first value in the storage.

Returns
A reference to the first value.

◆ Bottom() [2/2]

template<class KeyType, class DataType, class ArrayType, class HashFunc>
const DataType& Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::Bottom ( ) const
inline

Get a const reference to the first value in the storage.

Returns
A const reference to the first value.

◆ BottomKey()

template<class KeyType, class DataType, class ArrayType, class HashFunc>
const KeyType& Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::BottomKey ( ) const
inline

Get a const reference to the first key in the storage.

Returns
A const reference to the first key.

◆ Top() [1/2]

template<class KeyType, class DataType, class ArrayType, class HashFunc>
DataType& Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::Top ( )
inline

Get a reference to the last value in the storage.

Returns
A reference to the last value.

◆ Top() [2/2]

template<class KeyType, class DataType, class ArrayType, class HashFunc>
const DataType& Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::Top ( ) const
inline

Get a const reference to the last value in the storage.

Returns
A const reference to the last value.

◆ TopKey()

template<class KeyType, class DataType, class ArrayType, class HashFunc>
const KeyType& Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::TopKey ( ) const
inline

Get a const reference to the last key in the storage.

Returns
A const reference to the last key.

Referenced by Murl::MapBase< Murl::String, SystemFontDescriptor *, Array< SystemFontDescriptor * >, StdHash< Murl::String > >::PopKey().

◆ PopKey()

template<class KeyType, class DataType, class ArrayType, class HashFunc>
KeyType Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::PopKey ( )
inline

Remove the last key/value pair from the map and return its key.

Returns
The key of the removed pair.

◆ GetAlloc()

template<class KeyType, class DataType, class ArrayType, class HashFunc>
SInt32 Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::GetAlloc ( ) const
inline

Get the number of actually allocated pairs.

Returns
The number of allocated pairs.

◆ GetCount()

template<class KeyType, class DataType, class ArrayType, class HashFunc>
SInt32 Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::GetCount ( ) const
inline

◆ IsEmpty()

template<class KeyType, class DataType, class ArrayType, class HashFunc>
Bool Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::IsEmpty ( ) const
inline

Check if the map is empty.

Returns
true if the map is empty, false otherwise.

◆ KeyBegin()

template<class KeyType, class DataType, class ArrayType, class HashFunc>
KeyConstIterator Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::KeyBegin ( ) const
inline

Get the const key iterator to the first element.

Returns
The const key iterator to the first element.

◆ KeyEnd()

template<class KeyType, class DataType, class ArrayType, class HashFunc>
KeyConstIterator Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::KeyEnd ( ) const
inline

Get the const key iterator next to the last element.

Returns
The const key iterator next to the last element.

◆ KeyGetIter()

template<class KeyType, class DataType, class ArrayType, class HashFunc>
KeyConstIterator Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::KeyGetIter ( SInt32  index) const
inline

Get the const key iterator of a specified index.

Parameters
indexThe index for the key iterator.
Returns
The const key iterator or null if the index is out of range.

◆ Begin() [1/2]

template<class KeyType, class DataType, class ArrayType, class HashFunc>
ConstIterator Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::Begin ( ) const
inline

Get the const iterator to the first element.

Returns
The const iterator to the first element.

◆ End() [1/2]

template<class KeyType, class DataType, class ArrayType, class HashFunc>
ConstIterator Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::End ( ) const
inline

Get the const iterator next to the last element.

Returns
The const iterator next to the last element.

◆ GetIter() [1/2]

template<class KeyType, class DataType, class ArrayType, class HashFunc>
ConstIterator Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::GetIter ( SInt32  index) const
inline

Get the const iterator of a specified index.

Parameters
indexThe index for the iterator.
Returns
The const iterator or null if the index is out of range.

◆ Begin() [2/2]

template<class KeyType, class DataType, class ArrayType, class HashFunc>
Iterator Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::Begin ( )
inline

Get the iterator to the first element.

Returns
The iterator to the first element.

◆ End() [2/2]

template<class KeyType, class DataType, class ArrayType, class HashFunc>
Iterator Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::End ( )
inline

Get the iterator next to the last element.

Returns
The iterator next to the last element.

◆ GetIter() [2/2]

template<class KeyType, class DataType, class ArrayType, class HashFunc>
Iterator Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::GetIter ( SInt32  index)
inline

Get the iterator of a specified index.

Parameters
indexThe index for the iterator.
Returns
The iterator or null if the index is out of range.

◆ IsEqual()

template<class KeyType, class DataType, class ArrayType, class HashFunc>
Bool Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::IsEqual ( const MapBase< KeyType, DataType, ArrayType, HashFunc > &  other) const
inline

◆ operator==()

template<class KeyType, class DataType, class ArrayType, class HashFunc>
bool Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::operator== ( const MapBase< KeyType, DataType, ArrayType, HashFunc > &  rhs) const
inline

The "equal to" comparison operator, calls IsEqual().

Parameters
rhsThe right hand side map to compare.
Returns
true if all key value pairs have identical contents.

◆ operator!=()

template<class KeyType, class DataType, class ArrayType, class HashFunc>
bool Murl::MapBase< KeyType, DataType, ArrayType, HashFunc >::operator!= ( const MapBase< KeyType, DataType, ArrayType, HashFunc > &  rhs) const
inline

The "not equal to" comparison operator, calls IsEqual().

Parameters
rhsThe right hand side map to compare.
Returns
true if the maps differ.

The documentation for this class was generated from the following file:
  • murl_map_base.h


Copyright © 2011-2018 Spraylight GmbH.