![]() |
Murl Engine Lua Addon API
Version 1.0 beta
|
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
Clear the map and remove the underlying storage.
Clear()
Empty the map, but keep the underlying storage.
Empty()
Shrink the map so that the underlying key and value storage is only as large as necessary.
Shrink()
Reduce the map to a given number of items.
Trim(Integer n)
n | The new number of items in the map, must be smaller than the current item count. |
Reduce the map by removing a given number of items from the end.
Drop(Integer n)
n | The number of items to remove from the end. |
Reserve storage space. If the given size is less than the actual size, nothing is done.
Reserve(Integer n)
n | The number of items the underlying storage should hold. |
Remove any unlinked pairs from the map.
Sweep()
Set the key of a given index.
SetKey(Integer index, String key)
index | The index to replace. |
key | The new key. |
Add a new key/value pair to the map. The newly added value is initialized using the value type's default constructor.
key | The key under which the value can be retrieved. |
Add a key/value pair to the map. The newly added value is initialized using the given reference value's copy constructor.
Integer Add(String key, Integer value)
key | The key under which the value can be retrieved. |
value | The reference value to add. |
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.
key | The key under which the value can be retrieved. |
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.
Integer Put(String key, Integer value)
key | The key under which the value can be retrieved. |
value | The reference value to add. |
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.
Integer Insert(Integer index, String key)
index | The index where to insert the new pair. |
key | The key under which the value can be retrieved. |
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.
Integer Insert(Integer index, String key, Integer value)
index | The index where to insert the new pair. |
key | The key under which the value can be retrieved. |
value | The reference value to insert. |
Unlink the pair at a given index. Unlinked elements remain in the map, but are ignored by any search operations.
Unlink(Integer index)
index | The index of the pair to unlink. |
Unlink all pairs matching a given key. Unlinked elements remain in the map, but are ignored by any search operations.
key | The key for which to unlink all elements. |
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.
Integer UnlinkKey(String key, Integer hash)
key | The key for which to unlink all elements. |
hash | The precomputed hash value. |
Check if the pair at a given index is unlinked.
Boolean IsUnlinked(Integer index)
index | The index of the pair to check. |
Remove the key/value pair at a given position from the map.
Remove(Integer index)
index | The zero-based index from where to remove the pair. |
Remove a number of key/value pairs from the map at a given starting position.
Remove(Integer index, Integer count)
index | The zero-based index from where to remove the first pair. |
count | The number of subsequent pairs to remove. |
Remove a number of key/value pairs from the map at given positions.
Remove(Murl.Array.SInt32 sortedIndices)
sortedIndices | A sorted array of indices where to remove the items. |
Remove all pairs from the map that match a given key.
key | The key for which to remove the pairs. |
Find the first occurrence of a given key in the map.
key | The key to search for. |
Find the first occurrence of a given key in the map, using a precomputed hash value.
Integer Find(String key, Integer hash)
key | The key to search for. |
hash | The precomputed hash value. |
Find the last occurrence of a given key in the map.
key | The key to search for. |
Find the last occurrence of a given key in the map, using a precomputed hash value.
Integer FindLast(String key, Integer hash)
key | The key to search for. |
hash | The precomputed hash value. |
Find the next occurrence of a key that is specified by a given index.
Integer FindNext(Integer index)
index | The index of the pair containing the key to search for. |
Find the previous occurrence of a key that is specified by a given index.
Integer FindPrev(Integer index)
index | The index of the pair containing the key to search for. |
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.
key | The key to search for. |
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.
Integer FindAdd(String key, Integer value)
key | The key to search for. |
value | The reference value to add. |
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.
key | The key to search for. |
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.
Integer FindPut(String key, Integer value)
key | The key to search for. |
value | The reference value to add. |
Get a reference to the first occurrence of a given key in the map. If the key was not found, the behaviour is undefined.
key | The key to search for. |
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
Integer Get(String key, Integer defaultValue)
key | The key to search for. |
defaultValue | The default value to return if the key was not found. |
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.
key | The key to search for. |
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.
Integer GetAdd(String key, Integer value)
key | The key to search for. |
value | The reference value to add. |
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.
key | The key to search for. |
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.
Integer GetPut(String key, Integer value)
key | The key to search for. |
value | The reference value to add. |
Get a const reference to the key at a given index. If the index is out of range, the behaviour is undefined.
index | The index of the key to retrieve. |
Get a const reference to the key storage.
Murl.Index.String GetIndex()
Get a const reference to the array of keys.
Murl.Array.String GetKeys()
Get a const reference to the array of values.
Murl.Array.UInt32 GetValues()
Check if a given index is a valid index.
Boolean IsIndexValid(Integer index)
index | The index to check. |
Get a const reference to the first value in the storage.
Integer Bottom()
Get a const reference to the first key in the storage.
String BottomKey()
Get a const reference to the last value in the storage.
Integer Top()
Get a const reference to the last key in the storage.
String TopKey()
Remove the last key/value pair from the map and return its key.
String PopKey()
Get the number of actually allocated pairs.
Integer GetAlloc()
Get the number of items in the map.
Integer GetCount()
Check if the map is empty.
Boolean IsEmpty()
Compare the map to another one.
Boolean IsEqual(Murl.MapBase.StringUInt32ArrayUInt32StdHashString other)
other | The map to compare. |
The length operator is denoted by the unary prefix operator #.
Get a reference to the value at a given index. If the index is out of range, the behaviour is undefined.
index | The index of the value to retrieve. |
The "equal to" comparison operator, calls IsEqual().