Murl Engine Lua Addon API  Version 1.0 beta
Murl.Hash

A hash class.

The hash class stores indices accessable by a hash value.
This class is based on the NTL Hash container, see http://www.ultimatepp.org


Table members

Functions


Murl.Hash.new()

The default constructor. Create an empty hash object.

Murl.Hash new()

Returns
Murl.Hash

Murl.Hash.new(hash)

The copy constructor.

Murl.Hash new(Murl.Hash hash)

Parameters
hashThe hash object to copy.
Returns
Murl.Hash


Methods


Clear()

Clear the hash object.

Clear()


ClearIndex()

Clear the index.

ClearIndex()


Reindex()

Clear and rebuild the index.

Reindex()


Reindex(n)

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

Reindex(Integer n)

Parameters
nThe number of items to rebuild.

Shrink()

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

Shrink()


Trim(n)

Reduce the hash object to a given number of items.

Boolean Trim(Integer n)

Parameters
nThe new number of items in the hash object, must be smaller than the current item count.
Returns
Boolean true if successful.

Drop(n)

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

Boolean Drop(Integer n)

Parameters
nThe number of items to remove from the end.
Returns
Boolean true if successful.

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 a given index. Unlinked items remain in the hash object, but are ignored by any search operations.

Boolean Unlink(Integer index)

Parameters
indexThe index to unlink.
Returns
Boolean true if successful.

IsUnlinked(index)

Check if the given index is unlinked.

Boolean IsUnlinked(Integer index)

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

GetUnlinked()

Get an array of unlinked indices.

Murl.Array.SInt32 GetUnlinked()

Returns
Murl.Array.SInt32 The array of indices.

Set(index, hash)

Replace the index for a specified hash value.

Set(Integer index, Integer hash)

Parameters
indexThe index to set.
hashThe hash value to set.

SetUn(index, hash)

Replace the hash value at a specified index without consideration of multiple entries per hash value.

SetUn(Integer index, Integer hash)

Parameters
indexThe index to set.
hashThe hash value to set.

Add(hash)

Add a hash value.

Add(Integer hash)

Parameters
hashThe hash value to add.

Put(hash)

Put a hash value by replacing an unlinked index if present.

Integer Put(Integer hash)

Parameters
hashThe hash value to add.
Returns
Integer The index of the hash value or -1 if no unlinked index is available.

Insert(index, hash)

Insert an index for a given hash value.

Insert(Integer index, Integer hash)

Parameters
indexThe index to insert.
hashThe hash value to insert.

Remove(index)

Remove the hash value at a given position.

Remove(Integer index)

Parameters
indexThe index from where to remove the hash value.

Remove(index, count)

Remove a number of hash values at a given starting position.

Remove(Integer index, Integer count)

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

Find(hash)

Find the first index of a given hash value.

Integer Find(Integer hash)

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

FindNext(index)

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

Integer FindNext(Integer index)

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

FindPrev(index)

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

Integer FindPrev(Integer index)

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

FindLast(hash)

Find the last occurrence of a hash value.

Integer FindLast(Integer hash)

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

GetCount()

Get the number of items.

Integer GetCount()

Returns
Integer The number of items.

Swap(other)

Exchange the content of the hash object with a given second one.

Murl.Hash Swap(Murl.Hash other)

Parameters
otherThe second hash object.
Returns
Murl.Hash other The second hash object.


Metamethods


The length operator

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

Returns
GetCount()

The array subscript operator.

Get the hash value for a given index. If the index is out of range, the behaviour is undefined.

Parameters
indexThe index of the hash value to retrieve.
Returns
Integer = Murl.Hash [Integer index]