ajtable.c

Datatypes: AjPTable


Datatype: AjPTable

Hash tables

Sections: Constructors Destructors Retrieval Trace functions Adding values Map function to each value Modify Merging exit


Section: Constructors

Constructors for hash tables

Functions: ajTableNew ajTableNewFunctionLen


Function ajTableNew

creates, initialises, and returns a new, empty table that expects a specified number of key-value pairs.

Current method defines the table size as the number of entries divided by 4 to avoid a huge table.

Synopsis

Prototype
AjPTable ajTableNew (
      ajuint size
);

TypeNameRead/WriteDescription
ajuintsizeInputnumber of key-value pairs
AjPTable RETURNnew table.

Input
size:(Input)number of key-value pairs
Returns
AjPTable:new table.

Description

creates, initialises, and returns a new, empty table that expects a specified number of key-value pairs.

Current method defines the table size as the number of entries divided by 4 to avoid a huge table.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTableNewFunctionLen

creates, initialises, and returns a new, empty table that expects a specified number of key-value pairs.

Current method defines the table size as the number of entries divided by 4 to avoid a huge table.

Synopsis

Prototype
AjPTable ajTableNewFunctionLen (
      ajuint size,
      ajint function cmp,
      ajuint function hash,
      void function keydel,
      void function valdel
);

TypeNameRead/WriteDescription
ajuintsizeInputnumber of key-value pairs
ajint functioncmpFunctionfunction for comparing
ajuint functionhashFunctionfunction for hashing keys
void functionkeydelFunctionkey destructor function
void functionvaldelFunctionvalue destructor function
AjPTable RETURNnew table.

Input
size:(Input)number of key-value pairs
cmp:(Function)function for comparing
hash:(Function)function for hashing keys
keydel:(Function)key destructor function
valdel:(Function)value destructor function
Returns
AjPTable:new table.

Description

creates, initialises, and returns a new, empty table that expects a specified number of key-value pairs.

Current method defines the table size as the number of entries divided by 4 to avoid a huge table.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: Destructors

Functions: ajTableDel ajTableDelKeydelValdel ajTableDelValdel ajTableFree


Function ajTableDel

Deallocates and clears a hash table, and any keys or values.

Synopsis

Prototype
void ajTableDel (
      AjPTable* Ptable
);

TypeNameRead/WriteDescription
AjPTable*PtableDeleteTable (by reference)
void RETURN

Output
Ptable:(Delete)Table (by reference)
Returns
void:No return value

Description

Deallocates and clears a hash table, and any keys or values.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTableDelKeydelValdel

Deallocates and clears a hash table, and any keys or values.

Synopsis

Prototype
void ajTableDelKeydelValdel (
      AjPTable* Ptable,
      void function keydel,
      void function valdel
);

TypeNameRead/WriteDescription
AjPTable*PtableDeleteTable (by reference)
void functionkeydelFunctionkey destructor
void functionvaldelFunctionvalue destructor
void RETURN

Input
keydel:(Function)key destructor
valdel:(Function)value destructor
Output
Ptable:(Delete)Table (by reference)
Returns
void:No return value

Description

Deallocates and clears a hash table, and any keys or values.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTableDelValdel

Deallocates and clears a hash table, and any keys or values.

Synopsis

Prototype
void ajTableDelValdel (
      AjPTable* Ptable,
      void function valdel
);

TypeNameRead/WriteDescription
AjPTable*PtableDeleteTable (by reference)
void functionvaldelFunctionvalue destructor
void RETURN

Input
valdel:(Function)value destructor
Output
Ptable:(Delete)Table (by reference)
Returns
void:No return value

Description

Deallocates and clears a hash table, and any keys or values.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTableFree

Deallocates and clears a hash table. Does not clear keys or values.

Synopsis

Prototype
void ajTableFree (
      AjPTable* Ptable
);

TypeNameRead/WriteDescription
AjPTable*PtableDeleteTable (by reference)
void RETURN

Output
Ptable:(Delete)Table (by reference)
Returns
void:No return value

Description

Deallocates and clears a hash table. Does not clear keys or values.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: Retrieval

Functions: ajTableFetchC ajTableFetchS ajTableFetchV ajTableFetchmodC ajTableFetchmodS ajTableFetchmodV ajTableFetchmodTraceV ajTableGetLength ajTableGetSize ajTableMatchC ajTableMatchS ajTableMatchV ajTableToarrayKeys ajTableToarrayKeysValues ajTableToarrayValues


Function ajTableFetchC

returns the value associated with key in table, or null if table does not hold key.

Synopsis

Prototype
const void* ajTableFetchC (
      const AjPTable table,
      const char* txtkey
);

TypeNameRead/WriteDescription
const AjPTabletableInputtable to search
const char*txtkeyInputkey to find.
const void* RETURNvalue associated with key

Input
table:(Input)table to search
txtkey:(Input)key to find.
Returns
const void*:value associated with key

Description

returns the value associated with key in table, or null if table does not hold key.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTableFetchS

returns the value associated with key in table, or null if table does not hold key.

Synopsis

Prototype
const void* ajTableFetchS (
      const AjPTable table,
      const AjPStr key
);

TypeNameRead/WriteDescription
const AjPTabletableInputtable to search
const AjPStrkeyInputkey to find.
const void* RETURNvalue associated with key

Input
table:(Input)table to search
key:(Input)key to find.
Returns
const void*:value associated with key

Description

returns the value associated with key in table, or null if table does not hold key.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTableFetchV

Returns the value associated with key in table, or null if table does not hold key.

Synopsis

Prototype
const void* ajTableFetchV (
      const AjPTable table,
      const void* key
);

TypeNameRead/WriteDescription
const AjPTabletableInputtable to search
const void*keyInputkey to find.
const void* RETURNvalue associated with key

Input
table:(Input)table to search
key:(Input)key to find.
Returns
const void*:value associated with key

Description

Returns the value associated with key in table, or null if table does not hold key.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTableFetchmodC

returns the value associated with key in table, or null if table does not hold key.

Synopsis

Prototype
void* ajTableFetchmodC (
      const AjPTable table,
      const char* txtkey
);

TypeNameRead/WriteDescription
const AjPTabletableInputtable to search
const char*txtkeyInputkey to find.
void* RETURNvalue associated with key

Input
table:(Input)table to search
txtkey:(Input)key to find.
Returns
void*:value associated with key

Description

returns the value associated with key in table, or null if table does not hold key.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTableFetchmodS

returns the value associated with key in table, or null if table does not hold key.

Synopsis

Prototype
void* ajTableFetchmodS (
      const AjPTable table,
      const AjPStr key
);

TypeNameRead/WriteDescription
const AjPTabletableInputtable to search
const AjPStrkeyInputkey to find.
void* RETURNvalue associated with key

Input
table:(Input)table to search
key:(Input)key to find.
Returns
void*:value associated with key

Description

returns the value associated with key in table, or null if table does not hold key.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTableFetchmodV

Returns the value associated with key in table, or null if table does not hold key.

Synopsis

Prototype
void* ajTableFetchmodV (
      const AjPTable table,
      const void* key
);

TypeNameRead/WriteDescription
const AjPTabletableInputtable to search
const void*keyInputkey to find.
void* RETURNvalue associated with key

Input
table:(Input)table to search
key:(Input)key to find.
Returns
void*:value associated with key

Description

Returns the value associated with key in table, or null if table does not hold key.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTableFetchmodTraceV

Returns the value associated with key in table, or null if table does not hold key.

Trace internals with debug calls.

Synopsis

Prototype
void* ajTableFetchmodTraceV (
      const AjPTable table,
      const void* key
);

TypeNameRead/WriteDescription
const AjPTabletableInputtable to search
const void*keyInputkey to find.
void* RETURNvalue associated with key

Input
table:(Input)table to search
key:(Input)key to find.
Returns
void*:value associated with key

Description

Returns the value associated with key in table, or null if table does not hold key.

Trace internals with debug calls.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTableGetLength

returns the number of key-value pairs in table.

Synopsis

Prototype
ajuint ajTableGetLength (
      const AjPTable table
);

TypeNameRead/WriteDescription
const AjPTabletableInputTable to be applied.
ajuint RETURNnumber of key-value pairs.

Input
table:(Input)Table to be applied.
Returns
ajuint:number of key-value pairs.

Description

returns the number of key-value pairs in table.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTableGetSize

returns the size of the hash array in a table.

Synopsis

Prototype
ajuint ajTableGetSize (
      const AjPTable table
);

TypeNameRead/WriteDescription
const AjPTabletableInputTable to be applied.
ajuint RETURNnumber of hash array positions

Input
table:(Input)Table to be applied.
Returns
ajuint:number of hash array positions

Description

returns the size of the hash array in a table.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTableMatchC

Returns true if the key is found in the table

Used in place of ajTableFetchS where the value may be NULL

Synopsis

Prototype
AjBool ajTableMatchC (
      const AjPTable table,
      const char* txtkey
);

TypeNameRead/WriteDescription
const AjPTabletableInputtable to search
const char*txtkeyInputkey to find.
AjBool RETURNTrue if key was found[

Input
table:(Input)table to search
txtkey:(Input)key to find.
Returns
AjBool:True if key was found[

Description

Returns true if the key is found in the table

Used in place of ajTableFetchS where the value may be NULL

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTableMatchS

Returns true if the key is found in the table

Used in place of ajTableFetchS where the value may be NULL

Synopsis

Prototype
AjBool ajTableMatchS (
      const AjPTable table,
      const AjPStr key
);

TypeNameRead/WriteDescription
const AjPTabletableInputtable to search
const AjPStrkeyInputkey to find.
AjBool RETURNTrue if key was found

Input
table:(Input)table to search
key:(Input)key to find.
Returns
AjBool:True if key was found

Description

Returns true if the key is found in the table

Used in place of ajTableFetchS where the value may be NULL

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTableMatchV

Returns true if the key is found in the table

Used in place of ajTableFetchS where the value may be NULL

Synopsis

Prototype
AjBool ajTableMatchV (
      const AjPTable table,
      const void* key
);

TypeNameRead/WriteDescription
const AjPTabletableInputtable to search
const void*keyInputkey to find.
AjBool RETURNTrue if key was found

Input
table:(Input)table to search
key:(Input)key to find.
Returns
AjBool:True if key was found

Description

Returns true if the key is found in the table

Used in place of ajTableFetchS where the value may be NULL

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTableToarrayKeys

creates two N+1 element arrays that holds the N keys in table in an unspecified order and returns the number of elements. The final element of the array is NULL.

Synopsis

Prototype
ajuint ajTableToarrayKeys (
      const AjPTable table,
      void*** keyarray
);

TypeNameRead/WriteDescription
const AjPTabletableInputTable
void***keyarrayOutputNULL terminated array of keys.
ajuint RETURNsize of array returned

Input
table:(Input)Table
Output
keyarray:(Output)NULL terminated array of keys.
Returns
ajuint:size of array returned

Description

creates two N+1 element arrays that holds the N keys in table in an unspecified order and returns the number of elements. The final element of the array is NULL.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTableToarrayKeysValues

creates two N+1 element arrays that holds the N key-value pairs in table in an unspecified order and returns the number of elements. The final element of the array is NULL.

Synopsis

Prototype
ajuint ajTableToarrayKeysValues (
      const AjPTable table,
      void*** keyarray,
      void*** valarray
);

TypeNameRead/WriteDescription
const AjPTabletableInputTable
void***keyarrayOutputNULL terminated array of keys.
void***valarrayOutputNULL terminated array of values.
ajuint RETURNsize of arrays returned

Input
table:(Input)Table
Output
keyarray:(Output)NULL terminated array of keys.
valarray:(Output)NULL terminated array of values.
Returns
ajuint:size of arrays returned

Description

creates two N+1 element arrays that holds the N key-value pairs in table in an unspecified order and returns the number of elements. The final element of the array is NULL.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTableToarrayValues

creates two N+1 element arrays that holds the N values in table in an unspecified order and returns the number of elements. The final element of the array is NULL.

Synopsis

Prototype
ajuint ajTableToarrayValues (
      const AjPTable table,
      void*** valarray
);

TypeNameRead/WriteDescription
const AjPTabletableInputTable
void***valarrayOutputNULL terminated array of values.
ajuint RETURNsize of array returned

Input
table:(Input)Table
Output
valarray:(Output)NULL terminated array of values.
Returns
ajuint:size of array returned

Description

creates two N+1 element arrays that holds the N values in table in an unspecified order and returns the number of elements. The final element of the array is NULL.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: Trace functions

Functions: ajTableTrace


Function ajTableTrace

Writes debug messages to trace the contents of a table.

Synopsis

Prototype
void ajTableTrace (
      const AjPTable table
);

TypeNameRead/WriteDescription
const AjPTabletableInputTable
void RETURN

Input
table:(Input)Table
Returns
void:No return value

Description

Writes debug messages to trace the contents of a table.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: Adding values

Functions: ajTablePut ajTablePutClean ajTablePutTrace ajTableRemove ajTableRemoveKey


Function ajTablePut

change the value associated with key in table to value and returns the previous value, or adds key and value if table does not hold key, and returns null.

Synopsis

Prototype
void* ajTablePut (
      AjPTable table,
      void* key,
      void* value
);

TypeNameRead/WriteDescription
AjPTabletableModifyTable to add to
void*keyUnknownkey
void*valueModifyvalue of key
void* RETURNprevious value if key exists, NULL if not.

Input & Output
table:(Modify)Table to add to
value:(Modify)value of key
Returns
void*:previous value if key exists, NULL if not.

Description

change the value associated with key in table to value and returns the previous value, or adds key and value if table does not hold key, and returns null.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTablePutClean

change the value associated with key in table to value and returns the previous value, applying destructors to the given key and value, or adds key and value if table does not hold key, and returns null.

Synopsis

Prototype
AjBool ajTablePutClean (
      AjPTable table,
      void* key,
      void* value,
      void function keydel,
      void function valdel
);

TypeNameRead/WriteDescription
AjPTabletableModifyTable to add to
void*keyUnknownkey
void*valueModifyvalue of key
void functionkeydelFunctionkey destructor
void functionvaldelFunctionvalue destructor
AjBool RETURNprevious value was found and deleted.

Input
keydel:(Function)key destructor
valdel:(Function)value destructor
Input & Output
table:(Modify)Table to add to
value:(Modify)value of key
Returns
AjBool:previous value was found and deleted.

Description

change the value associated with key in table to value and returns the previous value, applying destructors to the given key and value, or adds key and value if table does not hold key, and returns null.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTablePutTrace

change the value associated with key in table to value and returns the previous value, or adds key and value if table does not hold key, and returns null. Trace the internals as the value is inserted.

Synopsis

Prototype
void* ajTablePutTrace (
      AjPTable table,
      void* key,
      void* value
);

TypeNameRead/WriteDescription
AjPTabletableModifyTable to add to
void*keyUnknownkey
void*valueModifyvalue of key
void* RETURNprevious value if key exists, NULL if not.

Input & Output
table:(Modify)Table to add to
value:(Modify)value of key
Returns
void*:previous value if key exists, NULL if not.

Description

change the value associated with key in table to value and returns the previous value, or adds key and value if table does not hold key, and returns null. Trace the internals as the value is inserted.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTableRemove

Removes the key-value pair from table and returns the removed value. If table does not hold key, ajTableRemove has no effect and returns null.

Synopsis

Prototype
void* ajTableRemove (
      AjPTable table,
      const void* key
);

TypeNameRead/WriteDescription
AjPTabletableModifyTable
const void*keyInputkey to be removed
void* RETURNremoved value.

Input
key:(Input)key to be removed
Input & Output
table:(Modify)Table
Returns
void*:removed value.

Description

Removes the key-value pair from table and returns the removed value. If table does not hold key, ajTableRemove has no effect and returns null.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTableRemoveKey

Removes the key-value pair from table and returns the removed value. If table does not hold key, ajTableRemove has no effect and returns null.

Synopsis

Prototype
void* ajTableRemoveKey (
      AjPTable table,
      const void* key,
      void** truekey
);

TypeNameRead/WriteDescription
AjPTabletableModifyTable
const void*keyInputkey to be removed
void**truekeyOutputtrue internal key returned, now owned by caller
void* RETURNremoved value.

Input
key:(Input)key to be removed
Output
truekey:(Output)true internal key returned, now owned by caller
Input & Output
table:(Modify)Table
Returns
void*:removed value.

Description

Removes the key-value pair from table and returns the removed value. If table does not hold key, ajTableRemove has no effect and returns null.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: Map function to each value

Functions: ajTableMap ajTableMapDel


Function ajTableMap

calls function 'apply' for each key-value in table in an unspecified order. The table keys should not be modified by function 'apply' although values can be updated.

See ajTableMapDel for a function that can delete.

Note: because of the properties of C it is difficult to check these are being called correctly. This is because the apply function uses void* arguments.

Synopsis

Prototype
void ajTableMap (
      AjPTable table,
      void function apply,
      void* cl
);

TypeNameRead/WriteDescription
AjPTabletableModifyTable.
void functionapplyFunctionfunction to be applied
void*clModifyStandard. Usually NULL. To be passed to apply
void RETURN

Input
apply:(Function)function to be applied
Input & Output
table:(Modify)Table.
cl:(Modify)Standard. Usually NULL. To be passed to apply
Returns
void:No return value

Description

calls function 'apply' for each key-value in table in an unspecified order. The table keys should not be modified by function 'apply' although values can be updated.

See ajTableMapDel for a function that can delete.

Note: because of the properties of C it is difficult to check these are being called correctly. This is because the apply function uses void* arguments.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTableMapDel

calls function 'apply' for each key-value in table in an unspecified order.

Keys in the table can be deleted - for example a function to delete a table entry. See ajTableMap for a function that is read-only

Synopsis

Prototype
void ajTableMapDel (
      AjPTable table,
      void function apply,
      void* cl
);

TypeNameRead/WriteDescription
AjPTabletableModifyTable.
void functionapplyFunctionfunction to be applied
void*clModifyStandard. Usually NULL. To be passed to apply
void RETURN

Input
apply:(Function)function to be applied
Input & Output
table:(Modify)Table.
cl:(Modify)Standard. Usually NULL. To be passed to apply
Returns
void:No return value

Description

calls function 'apply' for each key-value in table in an unspecified order.

Keys in the table can be deleted - for example a function to delete a table entry. See ajTableMap for a function that is read-only

See Also

See other functions in this section

Availability

In release 6.4.0

Section: Modify

Functions: ajTableClear ajTableClearDelete ajTableResizeCount ajTableResizeHashsize ajTableSetDestroy ajTableSetDestroyboth ajTableSetDestroykey ajTableSetDestroyvalue ajTableSettypeChar ajTableSettypeCharCase ajTableSettypeDefault ajTableSettypeInt ajTableSettypeLong ajTableSettypeString ajTableSettypeStringCase ajTableSettypeUint ajTableSettypeUlong ajTableSettypeUser


Function ajTableClear

Clears a hash table. Does not clear keys or values.

Synopsis

Prototype
void ajTableClear (
      AjPTable table
);

TypeNameRead/WriteDescription
AjPTabletableModifyTable
void RETURN

Input & Output
table:(Modify)Table
Returns
void:No return value

Description

Clears a hash table. Does not clear keys or values.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTableClearDelete

Clears a hash table. Deletes all keys or values.

Synopsis

Prototype
void ajTableClearDelete (
      AjPTable table
);

TypeNameRead/WriteDescription
AjPTabletableModifyTable
void RETURN

Input & Output
table:(Modify)Table
Returns
void:No return value

Description

Clears a hash table. Deletes all keys or values.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTableResizeCount

Resizes a hash table to a new number of expected values.

Synopsis

Prototype
void ajTableResizeCount (
      AjPTable table,
      ajuint size
);

TypeNameRead/WriteDescription
AjPTabletableModifyTable
ajuintsizeInputExpected number of key-value pairs
void RETURN

Input
size:(Input)Expected number of key-value pairs
Input & Output
table:(Modify)Table
Returns
void:No return value

Description

Resizes a hash table to a new number of expected values.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTableResizeHashsize

Resizes a hash table to a new size.

Synopsis

Prototype
void ajTableResizeHashsize (
      AjPTable table,
      ajuint hashsize
);

TypeNameRead/WriteDescription
AjPTabletableModifyTable
ajuinthashsizeInputExpected number of key-value pairs
void RETURN

Input
hashsize:(Input)Expected number of key-value pairs
Input & Output
table:(Modify)Table
Returns
void:No return value

Description

Resizes a hash table to a new size.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTableSetDestroy

Sets the destructor functions for keys and values

Synopsis

Prototype
void ajTableSetDestroy (
      AjPTable table,
      void function keydel,
      void function valdel
);

TypeNameRead/WriteDescription
AjPTabletableModifyTable
void functionkeydelFunctionkey destructor function
void functionvaldelFunctionvalue destructor function
void RETURN

Input
keydel:(Function)key destructor function
valdel:(Function)value destructor function
Input & Output
table:(Modify)Table
Returns
void:No return value

Description

Sets the destructor functions for keys and values

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTableSetDestroyboth

Sets the destructor functions values to be the same as for keys

Synopsis

Prototype
void ajTableSetDestroyboth (
      AjPTable table
);

TypeNameRead/WriteDescription
AjPTabletableModifyTable
void RETURN

Input & Output
table:(Modify)Table
Returns
void:No return value

Description

Sets the destructor functions values to be the same as for keys

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTableSetDestroykey

Sets the destructor functions for keys

Synopsis

Prototype
void ajTableSetDestroykey (
      AjPTable table,
      void function keydel
);

TypeNameRead/WriteDescription
AjPTabletableModifyTable
void functionkeydelFunctionkey destructor function
void RETURN

Input
keydel:(Function)key destructor function
Input & Output
table:(Modify)Table
Returns
void:No return value

Description

Sets the destructor functions for keys

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTableSetDestroyvalue

Sets the destructor functions for values

Synopsis

Prototype
void ajTableSetDestroyvalue (
      AjPTable table,
      void function valdel
);

TypeNameRead/WriteDescription
AjPTabletableModifyTable
void functionvaldelFunctionvalue destructor function
void RETURN

Input
valdel:(Function)value destructor function
Input & Output
table:(Modify)Table
Returns
void:No return value

Description

Sets the destructor functions for values

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTableSettypeChar

Resets a hash table to use C character string keys

Synopsis

Prototype
void ajTableSettypeChar (
      AjPTable table
);

TypeNameRead/WriteDescription
AjPTabletableModifyHash table
void RETURN

Input & Output
table:(Modify)Hash table
Returns
void:No return value

Description

Resets a hash table to use C character string keys

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTableSettypeCharCase

Resets a hash table to use case-insensitive C character string keys

Synopsis

Prototype
void ajTableSettypeCharCase (
      AjPTable table
);

TypeNameRead/WriteDescription
AjPTabletableModifyHash table
void RETURN

Input & Output
table:(Modify)Hash table
Returns
void:No return value

Description

Resets a hash table to use case-insensitive C character string keys

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTableSettypeDefault

Resets a hash table to use default keys

Synopsis

Prototype
void ajTableSettypeDefault (
      AjPTable table
);

TypeNameRead/WriteDescription
AjPTabletableModifyHash table
void RETURN

Input & Output
table:(Modify)Hash table
Returns
void:No return value

Description

Resets a hash table to use default keys

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTableSettypeInt

Resets a hash table to use integer keys

Synopsis

Prototype
void ajTableSettypeInt (
      AjPTable table
);

TypeNameRead/WriteDescription
AjPTabletableModifyHash table
void RETURN

Input & Output
table:(Modify)Hash table
Returns
void:No return value

Description

Resets a hash table to use integer keys

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTableSettypeLong

Resets a hash table to use long integer keys

Synopsis

Prototype
void ajTableSettypeLong (
      AjPTable table
);

TypeNameRead/WriteDescription
AjPTabletableModifyHash table
void RETURN

Input & Output
table:(Modify)Hash table
Returns
void:No return value

Description

Resets a hash table to use long integer keys

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTableSettypeString

Resets a hash table to use string keys

Synopsis

Prototype
void ajTableSettypeString (
      AjPTable table
);

TypeNameRead/WriteDescription
AjPTabletableModifyHash table
void RETURN

Input & Output
table:(Modify)Hash table
Returns
void:No return value

Description

Resets a hash table to use string keys

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTableSettypeStringCase

Resets a hash table to use case-insensitive string keys

Synopsis

Prototype
void ajTableSettypeStringCase (
      AjPTable table
);

TypeNameRead/WriteDescription
AjPTabletableModifyHash table
void RETURN

Input & Output
table:(Modify)Hash table
Returns
void:No return value

Description

Resets a hash table to use case-insensitive string keys

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTableSettypeUint

Resets a hash table to use unsigned integer keys

Synopsis

Prototype
void ajTableSettypeUint (
      AjPTable table
);

TypeNameRead/WriteDescription
AjPTabletableModifyHash table
void RETURN

Input & Output
table:(Modify)Hash table
Returns
void:No return value

Description

Resets a hash table to use unsigned integer keys

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTableSettypeUlong

Resets a hash table to use unsigned long integer keys

Synopsis

Prototype
void ajTableSettypeUlong (
      AjPTable table
);

TypeNameRead/WriteDescription
AjPTabletableModifyHash table
void RETURN

Input & Output
table:(Modify)Hash table
Returns
void:No return value

Description

Resets a hash table to use unsigned long integer keys

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTableSettypeUser

Resets a hash table to use user-defined keys

Synopsis

Prototype
void ajTableSettypeUser (
      AjPTable table,
      ajint function cmp,
      ajuint function hash
);

TypeNameRead/WriteDescription
AjPTabletableModifyHash table
ajint functioncmpFunctionfunction for comparing
ajuint functionhashFunctionfunction for hashing keys
void RETURN

Input
cmp:(Function)function for comparing
hash:(Function)function for hashing keys
Input & Output
table:(Modify)Hash table
Returns
void:No return value

Description

Resets a hash table to use user-defined keys

See Also

See other functions in this section

Availability

In release 6.4.0

Section: Merging

Merging two tables with matchng key and value types

Functions: ajTableMergeAnd ajTableMergeEor ajTableMergeNot ajTableMergeOr


Function ajTableMergeAnd

Merge two tables, keeping all keys that are in both tables

Synopsis

Prototype
AjBool ajTableMergeAnd (
      AjPTable thys,
      AjPTable table
);

TypeNameRead/WriteDescription
AjPTablethysModifyCurrent table
AjPTabletableModifyTable to be merged
AjBool RETURNTrue on success

Input & Output
thys:(Modify)Current table
table:(Modify)Table to be merged
Returns
AjBool:True on success

Description

Merge two tables, keeping all keys that are in both tables

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTableMergeEor

Merge two tables, keeping all keys that are in only one table

Synopsis

Prototype
AjBool ajTableMergeEor (
      AjPTable thys,
      AjPTable table
);

TypeNameRead/WriteDescription
AjPTablethysModifyCurrent table
AjPTabletableModifyTable to be merged
AjBool RETURNTrue on success

Input & Output
thys:(Modify)Current table
table:(Modify)Table to be merged
Returns
AjBool:True on success

Description

Merge two tables, keeping all keys that are in only one table

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTableMergeNot

Merge two tables, removing all keys that are not in the new table

Synopsis

Prototype
AjBool ajTableMergeNot (
      AjPTable thys,
      AjPTable table
);

TypeNameRead/WriteDescription
AjPTablethysModifyCurrent table
AjPTabletableModifyTable to be merged
AjBool RETURNTrue on success

Input & Output
thys:(Modify)Current table
table:(Modify)Table to be merged
Returns
AjBool:True on success

Description

Merge two tables, removing all keys that are not in the new table

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTableMergeOr

Merge two tables, adding all unique keys from the new table

Synopsis

Prototype
AjBool ajTableMergeOr (
      AjPTable thys,
      AjPTable table
);

TypeNameRead/WriteDescription
AjPTablethysModifyCurrent table
AjPTabletableModifyTable to be merged
AjBool RETURNTrue on success

Input & Output
thys:(Modify)Current table
table:(Modify)Table to be merged
Returns
AjBool:True on success

Description

Merge two tables, adding all unique keys from the new table

See Also

See other functions in this section

Availability

In release 6.4.0

Section: exit

Functions called on exit from the program by ajExit to do any necessary cleanup and to report internal statistics to the debug file

Functions: ajTableExit


Function ajTableExit

Prints a summary of table usage with debug calls

Synopsis

Prototype
void ajTableExit (
      void
);

TypeNameRead/WriteDescription
void RETURN

Returns
void:No return value

Description

Prints a summary of table usage with debug calls

See Also

See other functions in this section

Availability

In release 6.4.0

Section: Constructors

Constructors for hash tables

Functions: ajTablecharNew ajTablecharNewCase ajTablecharNewCaseConst ajTablecharNewConst


Function ajTablecharNew

Creates a table with a character string key.

Synopsis

Prototype
AjPTable ajTablecharNew (
      ajuint size
);

TypeNameRead/WriteDescription
ajuintsizeInputnumber of key-value pairs
AjPTable RETURNNew table object with a character string key.

Input
size:(Input)number of key-value pairs
Returns
AjPTable:New table object with a character string key.

Description

Creates a table with a character string key.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTablecharNewCase

Creates a table with a character string key and case insensitive searching.

Synopsis

Prototype
AjPTable ajTablecharNewCase (
      ajuint size
);

TypeNameRead/WriteDescription
ajuintsizeInputHash size estimate.
AjPTable RETURNNew table object with a character string key.

Input
size:(Input)Hash size estimate.
Returns
AjPTable:New table object with a character string key.

Description

Creates a table with a character string key and case insensitive searching.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTablecharNewCaseConst

Creates a table with a character string key and case insensitive searching.

Synopsis

Prototype
AjPTable ajTablecharNewCaseConst (
      ajuint size
);

TypeNameRead/WriteDescription
ajuintsizeInputHash size estimate.
AjPTable RETURNNew table object with a character string key.

Input
size:(Input)Hash size estimate.
Returns
AjPTable:New table object with a character string key.

Description

Creates a table with a character string key and case insensitive searching.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTablecharNewConst

Creates a table with a character string key.

Synopsis

Prototype
AjPTable ajTablecharNewConst (
      ajuint size
);

TypeNameRead/WriteDescription
ajuintsizeInputnumber of key-value pairs
AjPTable RETURNNew table object with a character string key.

Input
size:(Input)number of key-value pairs
Returns
AjPTable:New table object with a character string key.

Description

Creates a table with a character string key.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: Trace functions

Functions: ajTablecharPrint


Function ajTablecharPrint

Print function for a table with a character string key.

Synopsis

Prototype
void ajTablecharPrint (
      const AjPTable table
);

TypeNameRead/WriteDescription
const AjPTabletableInputTable.
void RETURN

Input
table:(Input)Table.
Returns
void:No return value

Description

Print function for a table with a character string key.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: Comparison functions

Functions: ajTablecharCmp ajTablecharCmpCase ajTablecharHash ajTablecharHashCase


Function ajTablecharCmp

Comparison function for a table with a character string key

Synopsis

Prototype
ajint ajTablecharCmp (
      const void* x,
      const void* y
);

TypeNameRead/WriteDescription
const void*xInputStandard argument. Item value.
const void*yInputStandard argument. Comparison item value.
ajint RETURNComparison result. Zero if equal, non-zero if different.

Input
x:(Input)Standard argument. Item value.
y:(Input)Standard argument. Comparison item value.
Returns
ajint:Comparison result. Zero if equal, non-zero if different.

Description

Comparison function for a table with a character string key

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTablecharCmpCase

Comparison function for a table with a character string key and case insensitivity.

Synopsis

Prototype
ajint ajTablecharCmpCase (
      const void* x,
      const void* y
);

TypeNameRead/WriteDescription
const void*xInputStandard argument. Item value.
const void*yInputStandard argument. Comparison item value.
ajint RETURNComparison result. Zero if equal, non-zero if different.

Input
x:(Input)Standard argument. Item value.
y:(Input)Standard argument. Comparison item value.
Returns
ajint:Comparison result. Zero if equal, non-zero if different.

Description

Comparison function for a table with a character string key and case insensitivity.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTablecharHash

Hash function for a table with a character string key

Synopsis

Prototype
ajuint ajTablecharHash (
      const void* key,
      ajuint hashsize
);

TypeNameRead/WriteDescription
const void*keyInputStandard argument. Table key.
ajuinthashsizeInputStandard argument. Estimated Hash size.
ajuint RETURNHash value.

Input
key:(Input)Standard argument. Table key.
hashsize:(Input)Standard argument. Estimated Hash size.
Returns
ajuint:Hash value.

Description

Hash function for a table with a character string key

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTablecharHashCase

Hash function for a table with a character string key and case insensitivity.

Synopsis

Prototype
ajuint ajTablecharHashCase (
      const void* key,
      ajuint hashsize
);

TypeNameRead/WriteDescription
const void*keyInputStandard argument. Table key.
ajuinthashsizeInputStandard argument. Estimated Hash size.
ajuint RETURNHash value.

Input
key:(Input)Standard argument. Table key.
hashsize:(Input)Standard argument. Estimated Hash size.
Returns
ajuint:Hash value.

Description

Hash function for a table with a character string key and case insensitivity.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: Constructors

Constructors for hash tables

Functions: ajTableintNew ajTableintNewConst


Function ajTableintNew

Creates, initialises, and returns a new, empty table that can hold a specified number of integer key-value pairs.

Synopsis

Prototype
AjPTable ajTableintNew (
      ajuint size
);

TypeNameRead/WriteDescription
ajuintsizeInputestimate of number of unique keys
AjPTable RETURNnew table.

Input
size:(Input)estimate of number of unique keys
Returns
AjPTable:new table.

Description

Creates, initialises, and returns a new, empty table that can hold a specified number of integer key-value pairs.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTableintNewConst

Creates, initialises, and returns a new, empty table that can hold a specified number of integer key-value pairs.

Synopsis

Prototype
AjPTable ajTableintNewConst (
      ajuint size
);

TypeNameRead/WriteDescription
ajuintsizeInputestimate of number of unique keys
AjPTable RETURNnew table.

Input
size:(Input)estimate of number of unique keys
Returns
AjPTable:new table.

Description

Creates, initialises, and returns a new, empty table that can hold a specified number of integer key-value pairs.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: Destructors

Functions: ajTableintFree ajTableintFreeKey


Function ajTableintFree

Free keys and value strings in a table and free the table. Use only where the keys and data in the table are real, and not just copies of pointers. Otherwise a call to ajTableFree is enough.

Synopsis

Prototype
void ajTableintFree (
      AjPTable* Ptable
);

TypeNameRead/WriteDescription
AjPTable*PtableDeleteTable
void RETURN

Output
Ptable:(Delete)Table
Returns
void:No return value

Description

Free keys and value strings in a table and free the table. Use only where the keys and data in the table are real, and not just copies of pointers. Otherwise a call to ajTableFree is enough.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTableintFreeKey

Free keys and value strings in a table and free the table. Use only where the keys in the table are real, and not just copies of pointers. Otherwise a call to ajTableFree is enough.

Synopsis

Prototype
void ajTableintFreeKey (
      AjPTable* Ptable
);

TypeNameRead/WriteDescription
AjPTable*PtableDeleteTable
void RETURN

Output
Ptable:(Delete)Table
Returns
void:No return value

Description

Free keys and value strings in a table and free the table. Use only where the keys in the table are real, and not just copies of pointers. Otherwise a call to ajTableFree is enough.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: Retrieval

Functions: ajTableintFetch


Function ajTableintFetch

returns the value associated with key in table, or null if table does not hold key.

Synopsis

Prototype
const ajint* ajTableintFetch (
      const AjPTable table,
      const ajint* intkey
);

TypeNameRead/WriteDescription
const AjPTabletableInputtable to search
const ajint*intkeyInputkey to find.
const ajint* RETURNvalue associated with key

Input
table:(Input)table to search
intkey:(Input)key to find.
Returns
const ajint*:value associated with key

Description

returns the value associated with key in table, or null if table does not hold key.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: Modify

Functions: ajTableintFetchmod


Function ajTableintFetchmod

returns the value associated with key in table, or null if table does not hold key.

Synopsis

Prototype
ajint* ajTableintFetchmod (
      AjPTable table,
      const ajint* intkey
);

TypeNameRead/WriteDescription
AjPTabletableModifytable to search
const ajint*intkeyInputkey to find.
ajint* RETURNvalue associated with key

Input
intkey:(Input)key to find.
Input & Output
table:(Modify)table to search
Returns
ajint*:value associated with key

Description

returns the value associated with key in table, or null if table does not hold key.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: Comparison functions

Functions: ajTableintCmp ajTableintHash


Function ajTableintCmp

Comparison function for a table with an integer key

Synopsis

Prototype
ajint ajTableintCmp (
      const void* x,
      const void* y
);

TypeNameRead/WriteDescription
const void*xInputStandard argument. Item value.
const void*yInputStandard argument. Comparison item value.
ajint RETURNComparison result. Zero if equal, non-zero if different.

Input
x:(Input)Standard argument. Item value.
y:(Input)Standard argument. Comparison item value.
Returns
ajint:Comparison result. Zero if equal, non-zero if different.

Description

Comparison function for a table with an integer key

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTableintHash

Hash function for a table with an integer key

Synopsis

Prototype
ajuint ajTableintHash (
      const void* key,
      ajuint hashsize
);

TypeNameRead/WriteDescription
const void*keyInputStandard argument. Table key.
ajuinthashsizeInputStandard argument. Estimated Hash size.
ajuint RETURNHash value in range 0 to hashsize-1

Input
key:(Input)Standard argument. Table key.
hashsize:(Input)Standard argument. Estimated Hash size.
Returns
ajuint:Hash value in range 0 to hashsize-1

Description

Hash function for a table with an integer key

See Also

See other functions in this section

Availability

In release 6.4.0

Section: Constructors

Constructors for hash tables

Functions: ajTablelongNew ajTablelongNewConst


Function ajTablelongNew

Creates, initialises, and returns a new, empty table that can hold a specified number of long integer key-value pairs.

Synopsis

Prototype
AjPTable ajTablelongNew (
      ajuint size
);

TypeNameRead/WriteDescription
ajuintsizeInputestimate of number of unique keys
AjPTable RETURNnew table.

Input
size:(Input)estimate of number of unique keys
Returns
AjPTable:new table.

Description

Creates, initialises, and returns a new, empty table that can hold a specified number of long integer key-value pairs.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTablelongNewConst

Creates, initialises, and returns a new, empty table that can hold a specified number of long integer key-value pairs.

Synopsis

Prototype
AjPTable ajTablelongNewConst (
      ajuint size
);

TypeNameRead/WriteDescription
ajuintsizeInputestimate of number of unique keys
AjPTable RETURNnew table.

Input
size:(Input)estimate of number of unique keys
Returns
AjPTable:new table.

Description

Creates, initialises, and returns a new, empty table that can hold a specified number of long integer key-value pairs.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: Destructors

Functions: ajTablelongFree ajTablelongFreeKey


Function ajTablelongFree

Free keys and value strings in a table and free the table. Use only where the keys and data in the table are real, and not just copies of pointers. Otherwise a call to ajTableFree is enough.

Synopsis

Prototype
void ajTablelongFree (
      AjPTable* Ptable
);

TypeNameRead/WriteDescription
AjPTable*PtableDeleteTable
void RETURN

Output
Ptable:(Delete)Table
Returns
void:No return value

Description

Free keys and value strings in a table and free the table. Use only where the keys and data in the table are real, and not just copies of pointers. Otherwise a call to ajTableFree is enough.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTablelongFreeKey

Free keys and value strings in a table and free the table. Use only where the keys in the table are real, and not just copies of pointers. Otherwise a call to ajTableFree is enough.

Synopsis

Prototype
void ajTablelongFreeKey (
      AjPTable* Ptable
);

TypeNameRead/WriteDescription
AjPTable*PtableDeleteTable
void RETURN

Output
Ptable:(Delete)Table
Returns
void:No return value

Description

Free keys and value strings in a table and free the table. Use only where the keys in the table are real, and not just copies of pointers. Otherwise a call to ajTableFree is enough.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: Retrieval

Functions: ajTablelongFetch


Function ajTablelongFetch

returns the value associated with key in table, or null if table does not hold key.

Synopsis

Prototype
const ajlong* ajTablelongFetch (
      const AjPTable table,
      const ajlong* longkey
);

TypeNameRead/WriteDescription
const AjPTabletableInputtable to search
const ajlong*longkeyInputkey to find.
const ajlong* RETURNvalue associated with key

Input
table:(Input)table to search
longkey:(Input)key to find.
Returns
const ajlong*:value associated with key

Description

returns the value associated with key in table, or null if table does not hold key.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: Modify

Functions: ajTablelongFetchmod


Function ajTablelongFetchmod

returns the value associated with key in table, or null if table does not hold key.

Synopsis

Prototype
ajlong* ajTablelongFetchmod (
      AjPTable table,
      const ajlong* longkey
);

TypeNameRead/WriteDescription
AjPTabletableModifytable to search
const ajlong*longkeyInputkey to find.
ajlong* RETURNvalue associated with key

Input
longkey:(Input)key to find.
Input & Output
table:(Modify)table to search
Returns
ajlong*:value associated with key

Description

returns the value associated with key in table, or null if table does not hold key.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: Comparison functions

Functions: ajTablelongCmp ajTablelongHash


Function ajTablelongCmp

Comparison function for a table with a long integer key

Synopsis

Prototype
ajint ajTablelongCmp (
      const void* x,
      const void* y
);

TypeNameRead/WriteDescription
const void*xInputStandard argument. Item value.
const void*yInputStandard argument. Comparison item value.
ajint RETURNComparison result. Zero if equal, non-zero if different.

Input
x:(Input)Standard argument. Item value.
y:(Input)Standard argument. Comparison item value.
Returns
ajint:Comparison result. Zero if equal, non-zero if different.

Description

Comparison function for a table with a long integer key

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTablelongHash

Hash function for a table with a long integer key

Synopsis

Prototype
ajuint ajTablelongHash (
      const void* key,
      ajuint hashsize
);

TypeNameRead/WriteDescription
const void*keyInputStandard argument. Table key.
ajuinthashsizeInputStandard argument. Estimated Hash size.
ajuint RETURNHash value in range 0 to hashsize-1

Input
key:(Input)Standard argument. Table key.
hashsize:(Input)Standard argument. Estimated Hash size.
Returns
ajuint:Hash value in range 0 to hashsize-1

Description

Hash function for a table with a long integer key

See Also

See other functions in this section

Availability

In release 6.4.0

Section: Constructors

Constructors for hash tables

Functions: ajTablestrNew ajTablestrNewCase ajTablestrNewCaseConst ajTablestrNewConst


Function ajTablestrNew

Creates, initialises, and returns a new, empty table that can hold a specified number of key-value pairs.

Synopsis

Prototype
AjPTable ajTablestrNew (
      ajuint size
);

TypeNameRead/WriteDescription
ajuintsizeInputestimate of number of unique keys
AjPTable RETURNnew table.

Input
size:(Input)estimate of number of unique keys
Returns
AjPTable:new table.

Description

Creates, initialises, and returns a new, empty table that can hold a specified number of key-value pairs.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTablestrNewCase

Creates, initialises, and returns a new, empty table that can hold a specified number of key-value pairs.

Synopsis

Prototype
AjPTable ajTablestrNewCase (
      ajuint size
);

TypeNameRead/WriteDescription
ajuintsizeInputestimate of number of unique keys
AjPTable RETURNnew table.

Input
size:(Input)estimate of number of unique keys
Returns
AjPTable:new table.

Description

Creates, initialises, and returns a new, empty table that can hold a specified number of key-value pairs.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTablestrNewCaseConst

Creates, initialises, and returns a new, empty table that can hold a specified number of key-value pairs.

Synopsis

Prototype
AjPTable ajTablestrNewCaseConst (
      ajuint size
);

TypeNameRead/WriteDescription
ajuintsizeInputestimate of number of unique keys
AjPTable RETURNnew table.

Input
size:(Input)estimate of number of unique keys
Returns
AjPTable:new table.

Description

Creates, initialises, and returns a new, empty table that can hold a specified number of key-value pairs.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTablestrNewConst

Creates, initialises, and returns a new, empty table that can hold a specified number of key-value pairs.

Synopsis

Prototype
AjPTable ajTablestrNewConst (
      ajuint size
);

TypeNameRead/WriteDescription
ajuintsizeInputestimate of number of unique keys
AjPTable RETURNnew table.

Input
size:(Input)estimate of number of unique keys
Returns
AjPTable:new table.

Description

Creates, initialises, and returns a new, empty table that can hold a specified number of key-value pairs.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: Destructors

Functions: ajTablestrFree ajTablestrFreeKey


Function ajTablestrFree

Free keys and value strings in a table and free the table. Use only where the keys and strings in the table are real, and not just copies of pointers. Otherwise a call to ajTableFree is enough.

Synopsis

Prototype
void ajTablestrFree (
      AjPTable* Ptable
);

TypeNameRead/WriteDescription
AjPTable*PtableDeleteTable
void RETURN

Output
Ptable:(Delete)Table
Returns
void:No return value

Description

Free keys and value strings in a table and free the table. Use only where the keys and strings in the table are real, and not just copies of pointers. Otherwise a call to ajTableFree is enough.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTablestrFreeKey

Free string keys in a table and free the table. Do not free the values. Use only where the keys in the table are real strings, and not just copies of pointers. Otherwise a call to ajTableFree is enough. The data is simply freed.

Synopsis

Prototype
void ajTablestrFreeKey (
      AjPTable* Ptable
);

TypeNameRead/WriteDescription
AjPTable*PtableDeleteTable
void RETURN

Output
Ptable:(Delete)Table
Returns
void:No return value

Description

Free string keys in a table and free the table. Do not free the values. Use only where the keys in the table are real strings, and not just copies of pointers. Otherwise a call to ajTableFree is enough. The data is simply freed.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: Retrieval

Functions: ajTablestrFetchC ajTablestrFetchS ajTablestrFetchkeyC ajTablestrFetchkeyS


Function ajTablestrFetchC

returns the value associated with key in table, or null if table does not hold key.

Synopsis

Prototype
void* ajTablestrFetchC (
      const AjPTable table,
      const char* txtkey
);

TypeNameRead/WriteDescription
const AjPTabletableInputtable to search
const char*txtkeyInputkey to find.
void* RETURNvalue associated with key

Input
table:(Input)table to search
txtkey:(Input)key to find.
Returns
void*:value associated with key

Description

returns the value associated with key in table, or null if table does not hold key.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTablestrFetchS

returns the value associated with key in table, or null if table does not hold key.

Synopsis

Prototype
void* ajTablestrFetchS (
      const AjPTable table,
      const AjPStr key
);

TypeNameRead/WriteDescription
const AjPTabletableInputtable to search
const AjPStrkeyInputkey to find.
void* RETURNvalue associated with key

Input
table:(Input)table to search
key:(Input)key to find.
Returns
void*:value associated with key

Description

returns the value associated with key in table, or null if table does not hold key.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTablestrFetchkeyC

returns the key value associated with key in table, or null if table does not hold key.

Intended for case-insensitive keys, to return the true key

Synopsis

Prototype
const AjPStr ajTablestrFetchkeyC (
      const AjPTable table,
      const char* txtkey
);

TypeNameRead/WriteDescription
const AjPTabletableInputtable to search
const char*txtkeyInputkey to find.
const AjPStr RETURNkey value as stored in the table

Input
table:(Input)table to search
txtkey:(Input)key to find.
Returns
const AjPStr:key value as stored in the table

Description

returns the key value associated with key in table, or null if table does not hold key.

Intended for case-insensitive keys, to return the true key

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTablestrFetchkeyS

returns the key value associated with key in table, or null if table does not hold key.

Intended for case-insensitive keys, to return the true key

Synopsis

Prototype
const AjPStr ajTablestrFetchkeyS (
      const AjPTable table,
      const AjPStr key
);

TypeNameRead/WriteDescription
const AjPTabletableInputtable to search
const AjPStrkeyInputkey to find.
const AjPStr RETURNkey value as stored in the table

Input
table:(Input)table to search
key:(Input)key to find.
Returns
const AjPStr:key value as stored in the table

Description

returns the key value associated with key in table, or null if table does not hold key.

Intended for case-insensitive keys, to return the true key

See Also

See other functions in this section

Availability

In release 6.4.0

Section: Modify

Functions: ajTablestrFetchmod


Function ajTablestrFetchmod

returns the value associated with key in table, or null if table does not hold key.

Synopsis

Prototype
AjPStr* ajTablestrFetchmod (
      AjPTable table,
      const AjPStr key
);

TypeNameRead/WriteDescription
AjPTabletableModifytable to search
const AjPStrkeyInputkey to find.
AjPStr* RETURNvalue associated with key

Input
key:(Input)key to find.
Input & Output
table:(Modify)table to search
Returns
AjPStr*:value associated with key

Description

returns the value associated with key in table, or null if table does not hold key.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: Comparison functions

Functions: ajTablestrCmp ajTablestrCmpCase ajTablestrHash ajTablestrHashCase


Function ajTablestrCmp

Comparison function for a table with a string key

Synopsis

Prototype
ajint ajTablestrCmp (
      const void* x,
      const void* y
);

TypeNameRead/WriteDescription
const void*xInputStandard argument. Item value.
const void*yInputStandard argument. Comparison item value.
ajint RETURNComparison result. Zero if equal, non-zero if different.

Input
x:(Input)Standard argument. Item value.
y:(Input)Standard argument. Comparison item value.
Returns
ajint:Comparison result. Zero if equal, non-zero if different.

Description

Comparison function for a table with a string key

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTablestrCmpCase

Comparison function for a table with a string key and case insensitivity.

Synopsis

Prototype
ajint ajTablestrCmpCase (
      const void* x,
      const void* y
);

TypeNameRead/WriteDescription
const void*xInputStandard argument. Item value.
const void*yInputStandard argument. Comparison item value.
ajint RETURNComparison result. Zero if equal, non-zero if different.

Input
x:(Input)Standard argument. Item value.
y:(Input)Standard argument. Comparison item value.
Returns
ajint:Comparison result. Zero if equal, non-zero if different.

Description

Comparison function for a table with a string key and case insensitivity.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTablestrHash

Hash function for a table with a string key

Synopsis

Prototype
ajuint ajTablestrHash (
      const void* key,
      ajuint hashsize
);

TypeNameRead/WriteDescription
const void*keyInputStandard argument. Table key.
ajuinthashsizeInputStandard argument. Estimated Hash size.
ajuint RETURNHash value in range 0 to hashsize-1

Input
key:(Input)Standard argument. Table key.
hashsize:(Input)Standard argument. Estimated Hash size.
Returns
ajuint:Hash value in range 0 to hashsize-1

Description

Hash function for a table with a string key

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTablestrHashCase

Hash function for a table with a string key and case insensitivity.

Synopsis

Prototype
ajuint ajTablestrHashCase (
      const void* key,
      ajuint hashsize
);

TypeNameRead/WriteDescription
const void*keyInputStandard argument. Table key.
ajuinthashsizeInputStandard argument. Estimated Hash size.
ajuint RETURNHash value in range 0 to hashsize-1

Input
key:(Input)Standard argument. Table key.
hashsize:(Input)Standard argument. Estimated Hash size.
Returns
ajuint:Hash value in range 0 to hashsize-1

Description

Hash function for a table with a string key and case insensitivity.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: Trace functions

Functions: ajTablestrPrint ajTablestrTrace ajTablestrTracekeys


Function ajTablestrPrint

Print function for a table with a string key.

Synopsis

Prototype
void ajTablestrPrint (
      const AjPTable table
);

TypeNameRead/WriteDescription
const AjPTabletableInputTable.
void RETURN

Input
table:(Input)Table.
Returns
void:No return value

Description

Print function for a table with a string key.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTablestrTrace

Writes debug messages to trace the contents of a table, assuming all keys and values are strings.

Synopsis

Prototype
void ajTablestrTrace (
      const AjPTable table
);

TypeNameRead/WriteDescription
const AjPTabletableInputTable
void RETURN

Input
table:(Input)Table
Returns
void:No return value

Description

Writes debug messages to trace the contents of a table, assuming all keys and values are strings.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTablestrTracekeys

Writes debug messages to trace the keys of a string table, assuming all keys and values are strings.

Synopsis

Prototype
void ajTablestrTracekeys (
      const AjPTable table
);

TypeNameRead/WriteDescription
const AjPTabletableInputTable
void RETURN

Input
table:(Input)Table
Returns
void:No return value

Description

Writes debug messages to trace the keys of a string table, assuming all keys and values are strings.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: Constructors

Constructors for hash tables

Functions: ajTableuintNew ajTableuintNewConst


Function ajTableuintNew

Creates, initialises, and returns a new, empty table that can hold a specified number of unsigned integer key-value pairs.

Synopsis

Prototype
AjPTable ajTableuintNew (
      ajuint size
);

TypeNameRead/WriteDescription
ajuintsizeInputestimate of number of unique keys
AjPTable RETURNnew table.

Input
size:(Input)estimate of number of unique keys
Returns
AjPTable:new table.

Description

Creates, initialises, and returns a new, empty table that can hold a specified number of unsigned integer key-value pairs.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTableuintNewConst

Creates, initialises, and returns a new, empty table that can hold a specified number of unsigned integer key-value pairs.

Synopsis

Prototype
AjPTable ajTableuintNewConst (
      ajuint size
);

TypeNameRead/WriteDescription
ajuintsizeInputestimate of number of unique keys
AjPTable RETURNnew table.

Input
size:(Input)estimate of number of unique keys
Returns
AjPTable:new table.

Description

Creates, initialises, and returns a new, empty table that can hold a specified number of unsigned integer key-value pairs.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: Destructors

Functions: ajTableuintFree ajTableuintFreeKey


Function ajTableuintFree

Free keys and value strings in a table and free the table. Use only where the keys and data in the table are real, and not just copies of pointers. Otherwise a call to ajTableFree is enough.

Synopsis

Prototype
void ajTableuintFree (
      AjPTable* Ptable
);

TypeNameRead/WriteDescription
AjPTable*PtableDeleteTable
void RETURN

Output
Ptable:(Delete)Table
Returns
void:No return value

Description

Free keys and value strings in a table and free the table. Use only where the keys and data in the table are real, and not just copies of pointers. Otherwise a call to ajTableFree is enough.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTableuintFreeKey

Free keys and value strings in a table and free the table. Use only where the keys in the table are real, and not just copies of pointers. Otherwise a call to ajTableFree is enough.

Synopsis

Prototype
void ajTableuintFreeKey (
      AjPTable* Ptable
);

TypeNameRead/WriteDescription
AjPTable*PtableDeleteTable
void RETURN

Output
Ptable:(Delete)Table
Returns
void:No return value

Description

Free keys and value strings in a table and free the table. Use only where the keys in the table are real, and not just copies of pointers. Otherwise a call to ajTableFree is enough.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: Retrieval

Functions: ajTableuintFetch


Function ajTableuintFetch

returns the value associated with key in table, or null if table does not hold key.

Synopsis

Prototype
const ajuint* ajTableuintFetch (
      const AjPTable table,
      const ajuint* uintkey
);

TypeNameRead/WriteDescription
const AjPTabletableInputtable to search
const ajuint*uintkeyInputkey to find.
const ajuint* RETURNvalue associated with key

Input
table:(Input)table to search
uintkey:(Input)key to find.
Returns
const ajuint*:value associated with key

Description

returns the value associated with key in table, or null if table does not hold key.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: Modify

Functions: ajTableuintFetchmod


Function ajTableuintFetchmod

returns the value associated with key in table, or null if table does not hold key.

Synopsis

Prototype
ajuint* ajTableuintFetchmod (
      AjPTable table,
      const ajuint* uintkey
);

TypeNameRead/WriteDescription
AjPTabletableModifytable to search
const ajuint*uintkeyInputkey to find.
ajuint* RETURNvalue associated with key

Input
uintkey:(Input)key to find.
Input & Output
table:(Modify)table to search
Returns
ajuint*:value associated with key

Description

returns the value associated with key in table, or null if table does not hold key.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: Comparison functions

Functions: ajTableuintCmp ajTableuintHash


Function ajTableuintCmp

Comparison function for a table with an unsigned integer key

Synopsis

Prototype
ajint ajTableuintCmp (
      const void* x,
      const void* y
);

TypeNameRead/WriteDescription
const void*xInputStandard argument. Item value.
const void*yInputStandard argument. Comparison item value.
ajint RETURNComparison result. Zero if equal, non-zero if different.

Input
x:(Input)Standard argument. Item value.
y:(Input)Standard argument. Comparison item value.
Returns
ajint:Comparison result. Zero if equal, non-zero if different.

Description

Comparison function for a table with an unsigned integer key

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTableuintHash

Hash function for a table with an unsigned integer key

Synopsis

Prototype
ajuint ajTableuintHash (
      const void* key,
      ajuint hashsize
);

TypeNameRead/WriteDescription
const void*keyInputStandard argument. Table key.
ajuinthashsizeInputStandard argument. Estimated Hash size.
ajuint RETURNHash value in range 0 to hashsize-1

Input
key:(Input)Standard argument. Table key.
hashsize:(Input)Standard argument. Estimated Hash size.
Returns
ajuint:Hash value in range 0 to hashsize-1

Description

Hash function for a table with an unsigned integer key

See Also

See other functions in this section

Availability

In release 6.4.0

Section: Constructors

Constructors for hash tables

Functions: ajTableulongNew ajTableulongNewConst


Function ajTableulongNew

Creates, initialises, and returns a new, empty table that can hold an arbitrary number of unsigned long integer key-value pairs

Synopsis

Prototype
AjPTable ajTableulongNew (
      ajuint size
);

TypeNameRead/WriteDescription
ajuintsizeInputestimate of number of unique keys
AjPTable RETURNnew table.

Input
size:(Input)estimate of number of unique keys
Returns
AjPTable:new table.

Description

Creates, initialises, and returns a new, empty table that can hold an arbitrary number of unsigned long integer key-value pairs

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTableulongNewConst

Creates, initialises, and returns a new, empty table that can hold an arbitrary number of unsigned long integer key-value pairs

Synopsis

Prototype
AjPTable ajTableulongNewConst (
      ajuint size
);

TypeNameRead/WriteDescription
ajuintsizeInputestimate of number of unique keys
AjPTable RETURNnew table.

Input
size:(Input)estimate of number of unique keys
Returns
AjPTable:new table.

Description

Creates, initialises, and returns a new, empty table that can hold an arbitrary number of unsigned long integer key-value pairs

See Also

See other functions in this section

Availability

In release 6.4.0

Section: Destructors

Functions: ajTableulongFree ajTableulongFreeKey


Function ajTableulongFree

Free keys and value strings in a table and free the table. Use only where the keys and data in the table are real, and not just copies of pointers. Otherwise a call to ajTableFree is enough.

Synopsis

Prototype
void ajTableulongFree (
      AjPTable* Ptable
);

TypeNameRead/WriteDescription
AjPTable*PtableDeleteTable
void RETURN

Output
Ptable:(Delete)Table
Returns
void:No return value

Description

Free keys and value strings in a table and free the table. Use only where the keys and data in the table are real, and not just copies of pointers. Otherwise a call to ajTableFree is enough.

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTableulongFreeKey

Free keys and value strings in a table and free the table. Use only where the keys in the table are real, and not just copies of pointers. Otherwise a call to ajTableFree is enough.

Synopsis

Prototype
void ajTableulongFreeKey (
      AjPTable* Ptable
);

TypeNameRead/WriteDescription
AjPTable*PtableDeleteTable
void RETURN

Output
Ptable:(Delete)Table
Returns
void:No return value

Description

Free keys and value strings in a table and free the table. Use only where the keys in the table are real, and not just copies of pointers. Otherwise a call to ajTableFree is enough.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: Retrieval

Functions: ajTableulongFetch


Function ajTableulongFetch

returns the value associated with key in table, or null if table does not hold key.

Synopsis

Prototype
const ajulong* ajTableulongFetch (
      const AjPTable table,
      const ajulong* ulongkey
);

TypeNameRead/WriteDescription
const AjPTabletableInputtable to search
const ajulong*ulongkeyInputkey to find.
const ajulong* RETURNvalue associated with key

Input
table:(Input)table to search
ulongkey:(Input)key to find.
Returns
const ajulong*:value associated with key

Description

returns the value associated with key in table, or null if table does not hold key.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: Modify

Functions: ajTableulongFetchmod


Function ajTableulongFetchmod

Returns the value associated with key in table, or null if table does not hold key.

Synopsis

Prototype
ajulong* ajTableulongFetchmod (
      AjPTable table,
      const ajulong* ulongkey
);

TypeNameRead/WriteDescription
AjPTabletableModifytable to search
const ajulong*ulongkeyInputkey to find.
ajulong* RETURNvalue associated with key

Input
ulongkey:(Input)key to find.
Input & Output
table:(Modify)table to search
Returns
ajulong*:value associated with key

Description

Returns the value associated with key in table, or null if table does not hold key.

See Also

See other functions in this section

Availability

In release 6.4.0

Section: Comparison functions

Functions: ajTableulongCmp ajTableulongHash


Function ajTableulongCmp

Comparison function for a table with an unsigned long integer key

Synopsis

Prototype
ajint ajTableulongCmp (
      const void* x,
      const void* y
);

TypeNameRead/WriteDescription
const void*xInputStandard argument. Item value.
const void*yInputStandard argument. Comparison item value.
ajint RETURNComparison result. Zero if equal, non-zero if different.

Input
x:(Input)Standard argument. Item value.
y:(Input)Standard argument. Comparison item value.
Returns
ajint:Comparison result. Zero if equal, non-zero if different.

Description

Comparison function for a table with an unsigned long integer key

See Also

See other functions in this section

Availability

In release 6.4.0

Function ajTableulongHash

Hash function for a table with an unsigned long integer key

Synopsis

Prototype
ajuint ajTableulongHash (
      const void* key,
      ajuint hashsize
);

TypeNameRead/WriteDescription
const void*keyInputStandard argument. Table key.
ajuinthashsizeInputStandard argument. Estimated Hash size.
ajuint RETURNHash value in range 0 to hashsize-1

Input
key:(Input)Standard argument. Table key.
hashsize:(Input)Standard argument. Estimated Hash size.
Returns
ajuint:Hash value in range 0 to hashsize-1

Description

Hash function for a table with an unsigned long integer key

See Also

See other functions in this section

Availability

In release 6.4.0