Murl Engine Lua Addon API  Version 1.0 beta
Murl.IndexBase.SInt32ArraySInt32StdHashSInt32

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


Table members

Methods


Clear()

Clear the index object and remove the underlying storage.

Clear()


ClearIndex()

Clear the hash index.

ClearIndex()


Empty()

Empty the index object, but keep the underlying storage.

Empty()


RebuildHash()

Clear and rebuild the hash index.

RebuildHash()


RebuildHash(n)

Clear and rebuild the hash index for a given number of items.

RebuildHash(Integer n)

Parameters
nThe number of items to rebuild.

Shrink()

Shrink the index object so that the underlying storage is only as large as necessary.

Shrink()


Trim(n)

Reduce the index object to a given number of items.

Trim(Integer n)

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

Drop(n)

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

Drop(Integer n)

Parameters
nThe number of items to remove from the end.

Reserve(n)

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

Reserve(Integer n)

Parameters
nThe number of items the underlying storage should hold.

Unlink(index)

Unlink the item at a given index. Unlinked items remain in the Index, but are ignored by any search operations.

Unlink(Integer index)

Parameters
indexThe index of the item to unlink.

UnlinkKey(key)

Unlink all items matching a given key. Unlinked items remain in the Index, but are ignored by any search operations.

Integer UnlinkKey(Integer key)

Parameters
keyThe key of the item(s) to unlink.
Returns
Integer The number of items that were unlinked.

UnlinkKey(key, hash)

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(Integer key, Integer hash)

Parameters
keyThe key of the item(s) to unlink.
hashThe pre calculated hash value.
Returns
Integer The number of items that were unlinked.

IsUnlinked(index)

Check if the item at a given index is unlinked.

Boolean IsUnlinked(Integer index)

Parameters
indexThe index of the item to check.
Returns
Boolean true if the specified item is unlinked.

HasUnlinked()

Check if the index has unlinked items.

Boolean HasUnlinked()

Returns
Boolean true if there is at least one unlinked item.

GetUnlinked()

Get an array of indices of all unlinked items.

Murl.Array.SInt32 GetUnlinked()

Returns
Murl.Array.SInt32 The array of indices.

Sweep()

Remove all unlinked items from the index.

Sweep()


Set(index, key)

Replace the item at a specified index.

Integer Set(Integer index, Integer key)

Parameters
indexThe index to set.
keyThe value to set.
Returns
Integer A reference to the set item.

Set(index, key, hash)

Replace the item at a specified index using a precomputed hash.

Integer Set(Integer index, Integer key, Integer hash)

Parameters
indexThe index to set.
keyThe value to set.
hashThe precomputed hash.
Returns
Integer A reference to the set item.

Add(key)

Add an item.

Integer Add(Integer key)

Parameters
keyThe item to add.
Returns
Integer A reference to the added item.

Add(key, hash)

Add an item with a precomputed hash value.

Integer Add(Integer key, Integer hash)

Parameters
keyThe item to add.
hashThe precomputed hash.
Returns
Integer A reference to the added item.

Put(key)

Add an item or replace an unlinked item if present.

Integer Put(Integer key)

Parameters
keyThe item to add.
Returns
Integer The index of the item.

Put(key, hash)

Add an item or replace an unlinked item if present, using a precomputed hash value.

Integer Put(Integer key, Integer hash)

Parameters
keyThe item to add.
hashThe precomputed hash.
Returns
Integer The index of the item.

FindAdd(key)

Find the first occurrence of a given item in the index, or add an item if the item was not found.

Integer FindAdd(Integer key)

Parameters
keyThe item to search for and add.
Returns
Integer The index of the item.

FindAdd(key, hash)

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(Integer key, Integer hash)

Parameters
keyThe item to search for and add.
hashThe precomputed hash.
Returns
Integer The index of the item.

FindPut(key)

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.

Integer FindPut(Integer key)

Parameters
keyThe item to search for and add.
Returns
Integer The index of the item.

FindPut(key, hash)

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(Integer key, Integer hash)

Parameters
keyThe item to search for and add.
hashThe precomputed hash.
Returns
Integer The index of the item.

Find(key)

Find the first occurrence of a given item.

Integer Find(Integer key)

Parameters
keyThe item to search for.
Returns
Integer The index of the item, or -1 if not found.

Find(key, hash)

Find the first occurrence of a given item using a precomputed hash value.

Integer Find(Integer key, Integer hash)

Parameters
keyThe item to search for.
hashThe precomputed hash.
Returns
Integer The index of the item, or -1 if not found.

FindNext(index)

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

Integer FindNext(Integer index)

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

FindPrev(index)

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

Integer FindPrev(Integer index)

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

FindLast(key)

Find the last occurrence of a given item.

Integer FindLast(Integer key)

Parameters
keyThe item to search for.
Returns
Integer The index of the item, or -1 if not found.

FindLast(key, hash)

Find the last occurrence of a given item, using a precomputed hash value.

Integer FindLast(Integer key, Integer hash)

Parameters
keyThe item to search for.
hashThe precomputed hash value.
Returns
Integer The index of the item, or -1 if not found.

Insert(index, key)

Insert an item at a given position.

Integer Insert(Integer index, Integer key)

Parameters
indexThe index where to insert the item.
keyThe item to insert.
Returns
Integer A reference to the inserted item.

Insert(index, key, hash)

Insert an item at a given position, using a precomputed hash value.

Integer Insert(Integer index, Integer key, Integer hash)

Parameters
indexThe index where to insert the item.
keyThe item to insert.
hashThe precomputed hash value.
Returns
Integer A reference to the inserted item.

Remove(index)

Remove the item at a given position.

Remove(Integer index)

Parameters
indexThe index from where to remove the item.

Remove(index, count)

Remove a number of items at a given starting position.

Remove(Integer index, Integer count)

Parameters
indexThe index from where to start removing the items.
countThe number of subsequent items to remove.

Remove(sortedIndices)

Remove a number of items at given positions.

Remove(Murl.Array.SInt32 sortedIndices)

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

RemoveKey(key)

Remove all items that match a given item.

Integer RemoveKey(Integer key)

Parameters
keyThe item to remove.
Returns
Integer The number of items that were removed.

RemoveKey(key, hash)

Remove all items that match a given item, using a precomputed hash value.

Integer RemoveKey(Integer key, Integer hash)

Parameters
keyThe item to remove.
hashThe precomputed hash value.
Returns
Integer The number of items that were removed.

Front()

Get a reference to the first item. Synonymous to Bottom().

Integer Front()

Returns
Integer A reference to the first item.

Back()

Get a reference to the last item. Synonymous to Top().

Integer Back()

Returns
Integer A reference to the last item.

Bottom()

Get a reference to the first item.

Integer Bottom()

Returns
Integer A reference to the first item.

Top()

Get a reference to the last item.

Integer Top()

Returns
Integer A reference to the last item.

IsIndexValid(index)

Check if a given index is a valid index.

Boolean IsIndexValid(Integer index)

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

Get(index)

Get a const reference to the item at a given index. If the index is out of range, the behaviour is undefined.

Integer Get(Integer index)

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

GetAlloc()

Get the number of actually allocated items.

Integer GetAlloc()

Returns
Integer The number of allocated items.

GetCount()

Get the number of items.

Integer GetCount()

Returns
Integer The number of items.

IsEmpty()

Check if the Index is empty.

Boolean IsEmpty()

Returns
Boolean true if the Index is empty, false otherwise.

GetKeys()

Get a const reference to the array of items.

Murl.Array.SInt32 GetKeys()

Returns
Murl.Array.SInt32 A const reference to the underlying item storage array.

CalculateHash(key)

Calculate the hash for an item.

Integer CalculateHash(Integer key)

Parameters
keyThe item to calculate.
Returns
Integer The hash value of the item.

IsEqual(other)

Compare the index to another one.

Boolean IsEqual(Murl.IndexBase.SInt32ArraySInt32StdHashSInt32 other)

Parameters
otherThe index to compare.
Returns
Boolean true if all keys have identical contents.


Metamethods


The length operator

The length operator is denoted by the unary prefix operator #.

Returns
GetCount()

The array subscript operator.

Get a const reference to the item at a given index. If the index is out of range, the behaviour is undefined.

Parameters
indexThe index of the item to retrieve.
Returns
Integer = Murl.IndexBase.SInt32ArraySInt32StdHashSInt32 [Integer index]

The equal to operator.

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

Returns
Boolean = Murl.IndexBase.SInt32ArraySInt32StdHashSInt32 == Murl.IndexBase.SInt32ArraySInt32StdHashSInt32