![]() |
Murl Engine Lua Addon API
Version 1.0 beta
|
A generic index template base class.
The index class stores a number of (not necessarily unique) keys in a hash table.
This is the base class of the Index and ObjectIndex class.
This class is based on the NTL AIndex container, see http://www.ultimatepp.org
Clear the index object and remove the underlying storage.
Clear()
Clear the hash index.
ClearIndex()
Empty the index object, but keep the underlying storage.
Empty()
Clear and rebuild the hash index.
RebuildHash()
Clear and rebuild the hash index for a given number of items.
RebuildHash(Integer n)
n | The number of items to rebuild. |
Shrink the index object so that the underlying storage is only as large as necessary.
Shrink()
Reduce the index object to a given number of items.
Trim(Integer n)
n | The new number of items in the index, must be smaller than the current item count. |
Reduce the index object 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. |
Unlink the item at a given index. Unlinked items remain in the Index, but are ignored by any search operations.
Unlink(Integer index)
index | The index of the item to unlink. |
Unlink all items matching a given key. Unlinked items remain in the Index, but are ignored by any search operations.
key | The key of the item(s) to unlink. |
Unlink all items matching a given key, using a pre calculated hash value. Unlinked items remain in the Index, but are ignored by any search operations.
Integer UnlinkKey(Number key, Integer hash)
key | The key of the item(s) to unlink. |
hash | The pre calculated hash value. |
Check if the item at a given index is unlinked.
Boolean IsUnlinked(Integer index)
index | The index of the item to check. |
Check if the index has unlinked items.
Boolean HasUnlinked()
Get an array of indices of all unlinked items.
Murl.Array.SInt32 GetUnlinked()
Remove all unlinked items from the index.
Sweep()
Replace the item at a specified index.
Number Set(Integer index, Number key)
index | The index to set. |
key | The value to set. |
Replace the item at a specified index using a precomputed hash.
Number Set(Integer index, Number key, Integer hash)
index | The index to set. |
key | The value to set. |
hash | The precomputed hash. |
Add an item.
key | The item to add. |
Add an item with a precomputed hash value.
Number Add(Number key, Integer hash)
key | The item to add. |
hash | The precomputed hash. |
Add an item or replace an unlinked item if present.
key | The item to add. |
Add an item or replace an unlinked item if present, using a precomputed hash value.
Integer Put(Number key, Integer hash)
key | The item to add. |
hash | The precomputed hash. |
Find the first occurrence of a given item in the index, or add an item if the item was not found.
key | The item to search for and add. |
Find the first occurrence of a given item in the index, or add an item if the item was not found, using a precomputed hash value.
Integer FindAdd(Number key, Integer hash)
key | The item to search for and add. |
hash | The precomputed hash. |
Find the first occurrence of a given item or put the item if the item was not found. Hereby replacing an unlinked element if possible.
key | The item to search for and add. |
Find the first occurrence of a given item or add the item if the item was not found, using a precomputed hash value. Hereby replacing an unlinked element if possible.
Integer FindPut(Number key, Integer hash)
key | The item to search for and add. |
hash | The precomputed hash. |
Find the first occurrence of a given item.
key | The item to search for. |
Find the first occurrence of a given item using a precomputed hash value.
Integer Find(Number key, Integer hash)
key | The item to search for. |
hash | The precomputed hash. |
Find the next occurrence of an item that is specified by a given index.
Integer FindNext(Integer index)
index | The index of the item containing the key to search for. |
Find the previous occurrence of an item that is specified by a given index.
Integer FindPrev(Integer index)
index | The index of the item containing the key to search for. |
Find the last occurrence of a given item.
key | The item to search for. |
Find the last occurrence of a given item, using a precomputed hash value.
Integer FindLast(Number key, Integer hash)
key | The item to search for. |
hash | The precomputed hash value. |
Insert an item at a given position.
Number Insert(Integer index, Number key)
index | The index where to insert the item. |
key | The item to insert. |
Insert an item at a given position, using a precomputed hash value.
Number Insert(Integer index, Number key, Integer hash)
index | The index where to insert the item. |
key | The item to insert. |
hash | The precomputed hash value. |
Remove the item at a given position.
Remove(Integer index)
index | The index from where to remove the item. |
Remove a number of items at a given starting position.
Remove(Integer index, Integer count)
index | The index from where to start removing the items. |
count | The number of subsequent items to remove. |
Remove a number of items at given positions.
Remove(Murl.Array.SInt32 sortedIndices)
sortedIndices | A sorted array of indices where to remove the items. |
Remove all items that match a given item.
key | The item to remove. |
Remove all items that match a given item, using a precomputed hash value.
Integer RemoveKey(Number key, Integer hash)
key | The item to remove. |
hash | The precomputed hash value. |
Get a reference to the first item. Synonymous to Bottom().
Number Front()
Get a reference to the last item. Synonymous to Top().
Number Back()
Get a reference to the first item.
Number Bottom()
Get a reference to the last item.
Number Top()
Check if a given index is a valid index.
Boolean IsIndexValid(Integer index)
index | The index to check. |
Get a const reference to the item at a given index. If the index is out of range, the behaviour is undefined.
index | The index of the item to retrieve. |
Get the number of actually allocated items.
Integer GetAlloc()
Get the number of items.
Integer GetCount()
Check if the Index is empty.
Boolean IsEmpty()
Get a const reference to the array of items.
Murl.Array.Real GetKeys()
Calculate the hash for an item.
Integer CalculateHash(Number key)
key | The item to calculate. |
Compare the index to another one.
Boolean IsEqual(Murl.IndexBase.RealArrayRealStdHashReal other)
other | The index to compare. |
The length operator is denoted by the unary prefix operator #.
Get a const reference to the item at a given index. If the index is out of range, the behaviour is undefined.
index | The index of the item to retrieve. |
The "equal to" comparison operator, calls IsEqual().