ajtable
Hash table object. Tables are key/value pairs with a simple hash function
to provide rapid searching for keys.
Tables can hold any data type. Special functions are available for
tables of AjPStr values, but these are in the ajstr library,
and start with ajStrTable...
In general, these functions are the same
but with different hash and comparison functions used. Alternative
function names are provided in all cases to save remembering which
calls need special cases.
Constructor(s)
Destructor(s)
Name | Description |
ajTableFree | Deallocates and clears a table.
|
Modifier(s)
Name | Description |
ajTablePut | Adds or updates a value for a given key.
|
ajTableMap | Calls a function for each key/value in a table.
|
ajTableRemove | Removes a key/value pair from a table, and returns
the value.
|
Cast(s)
Name | Description |
ajTableToarray | Creates an array to hold each key value pair
in pairs of array elements. The last element is null.
|
ajTableGet | Returns the value for a given key.
|
ajTableLength | Returns the number of keys in a table.
|
Output
Name | Description |
ajTableTrace | Writes debug messages to trace the contents of a table.
|
Attributes
Name | Type | Description |
cmp | (ajint*) | Compare function(0 for match, -1 or +1 if not matched)
|
hash | (unsigned*) | Hash function
|
defdel | (void*) | Default key destructor, or NULL if none
|
keydel | (void*) | Key destructor, or NULL if not an object
|
valdel | (void*) | Value destructor, or NULL if not an object
|
buckets | struct binding** | Buckets
|
length | ajuint | Number of entries
|
timestamp | ajuint | Time stamp
|
size | ajuint | Size - number of hash buckets
|
Use | ajuint | Reference count
|
Type | AjEnum | Enumerated type
|
Padding | char[4] | Padding to alignment boundary
|