Hashtables
Hashtables package is an implementation of hashtables in Gothic. Currently (version 2.8.0) only integers are supported as keys. The Hashtables grow automatically.
Dependencies
Initialization
Initialize with LeGo_PermMem
flag.
Implementation
Functions
HT_CreateSized
Generates a hashtable of the specified size.
var int size
Size of the hashtable to be created
Return value
The function returns a handle to the created hashtable.
HT_Create
Generates a standard size hashtable.
The function returns a handle to the created hashtable.
HT_Insert
Inserts a value into the Hashtable.
var int handle
Handle of a hashtablevar int val
The value to be insertedvar int key
The key associated with the value
HT_Resize
Changes the size of the hashtable (usually not necessary as it happens automatically).
var int handle
Handle of a hashtablevar int size
The new size of the hashtable
HT_Get
Reads a value from the hashtable.
var int handle
Handle of a hashtablevar int key
The key whose value is to be read
Return value
The function returns the value associated with the key.
HT_Has
Checks if the key already exist in hashtable.
var int handle
Handle of a hashtablevar int key
The key to be checked Return value
The function returns TRUE
if the key exist, FALSE
is returned otherwise.
HT_Remove
Removes a key from the hashtable.
var int handle
Handle of a hashtablevar int key
The key to be removed
HT_Change
Changes the value of a key already existing in the hashtable.
var int handle
Handle of a hashtablevar int val
The new valuevar int key
The key whose value is to be changed
HT_InsertOrChange
Inserts a value into the Hashtable, or changes the value if the key already exist into hashtable.
var int handle
Handle of a hashtablevar int val
The new valuevar int key
The key whose value is to be changed or associated with the value.
HT_GetNumber
Returns the number of entries in a hashtable.
var int handle
Handle of a hashtable
Return value
The function returns the number of entries in the hashtable.
HT_ForEach
Performs a function for each value pair in the hashtable.
var int handle
Handle of a hashtablevar func fnc
A function with signature void(int key, int val)
HT_Destroy
Deletes the hashtable.
var int handle
The handle of the hashtable to be deleted