ajtable


Data type AjPTable

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)

NameDescription
ajTableNewCreates a table.

Destructor(s)

NameDescription
ajTableFreeDeallocates and clears a table.

Modifier(s)

NameDescription
ajTablePutAdds or updates a value for a given key.
ajTableMapCalls a function for each key/value in a table.
ajTableRemoveRemoves a key/value pair from a table, and returns the value.

Cast(s)

NameDescription
ajTableToarrayCreates an array to hold each key value pair in pairs of array elements. The last element is null.
ajTableGetReturns the value for a given key.
ajTableLengthReturns the number of keys in a table.

Output

NameDescription
ajTableTraceWrites debug messages to trace the contents of a table.

Attributes

NameTypeDescription
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
bucketsstruct binding**Buckets
lengthajuintNumber of entries
timestampajuintTime stamp
sizeajuintSize - number of hash buckets
UseajuintReference count
TypeAjEnumEnumerated type
Paddingchar[4]Padding to alignment boundary