|
UFO: Alien Invasion
|
Header file for hashtable. More...

Go to the source code of this file.
Macros | |
| #define | HASHTABLE_H |
Typedefs | |
| typedef unsigned short int | HASH_INDEX |
| typedef unsigned short int(* | hashTable_hash) (const void *key, int len) |
| typedef int(* | hashTable_compare) (const void *key1, int len1, const void *key2, int len2) |
Functions | |
| hashTable_s * | HASH_NewTable (bool ownsKeys, bool ownsValues, bool duplicateOverwrite) |
| Creates a new hash table and sets it initial capacity. | |
| hashTable_s * | HASH_NewTable (bool ownsKeys, bool ownsValues, bool duplicateOverwrite, hashTable_hash h, hashTable_compare c) |
| Creates a new hash table and sets it initial capacity. | |
| hashTable_s * | HASH_NewTable (bool ownsKeys, bool ownsValues, bool duplicateOverwrite, hashTable_hash h, hashTable_compare c, memPool_t *keys, memPool_t *values, memPool_t *table) |
| Creates a new hash table and sets it initial capacity. | |
| hashTable_s * | HASH_CloneTable (hashTable_s *source) |
| void | HASH_DeleteTable (hashTable_s **t) |
| Deletes a hash table and sets the pointer to NULL. | |
| bool | HASH_Insert (hashTable_s *t, const void *key, int nkey, const void *value, int nvalue) |
| Inserts a new value with given key into the hash table. | |
| void * | HASH_Remove (hashTable_s *t, const void *key, int nkey) |
| Removes an existing value with given key from the hash table. | |
| void | HASH_Clear (hashTable_s *t) |
| Clears the hash table. | |
| void * | HASH_Get (hashTable_s *t, const void *key, int nkey) |
| Returns the value for a given key. | |
| int | HASH_Count (hashTable_s *t) |
| Returns the number of entries in the hash table. | |
Header file for hashtable.
Definition in file hashtable.h.
| #define HASHTABLE_H |
Definition at line 40 of file hashtable.h.
| typedef unsigned short int HASH_INDEX |
The hash uses a 256 byte table, so we define a index type here The hash function signature.
Definition at line 49 of file hashtable.h.
Definition at line 53 of file hashtable.h.
The compare function signature.
Definition at line 51 of file hashtable.h.
| void HASH_Clear | ( | hashTable_s * | t | ) |
| hashTable_s * HASH_CloneTable | ( | hashTable_s * | source | ) |
Definition at line 336 of file hashtable.cpp.
References _iterator_first(), _iterator_next(), hashTable_s::compare, hashTable_s::duplicateOverwrite, hashTable_s::hash, HASH_Insert(), HASH_NewTable(), hashItem_s::key, hashItem_s::nkey, hashItem_s::nvalue, hashTable_s::ownsKeys, hashTable_s::ownsValues, and hashItem_s::value.
Referenced by UI_CloneNode().
| int HASH_Count | ( | hashTable_s * | t | ) |
Returns the number of entries in the hash table.
Definition at line 481 of file hashtable.cpp.
References hashBucket_s::count, HASH_TABLE_SIZE, i, and hashTable_s::table.
| void HASH_DeleteTable | ( | hashTable_s ** | t | ) |
Deletes a hash table and sets the pointer to NULL.
| [in,out] | t | A reference to a hashTable_s pointer. |
Definition at line 351 of file hashtable.cpp.
References _release_table().
Referenced by CL_ShutdownLua(), and uiNode::deleteNode().
| void * HASH_Get | ( | hashTable_s * | t, |
| const void * | key, | ||
| int | nkey ) |
Returns the value for a given key.
Definition at line 467 of file hashtable.cpp.
References _find_bucket_entry(), hashTable_s::compare, hashTable_s::hash, i, key, and hashTable_s::table.
Referenced by CL_ExecuteCallback(), UI_GetBehaviourMethod(), and UI_GetNodeMethod().
| bool HASH_Insert | ( | hashTable_s * | t, |
| const void * | key, | ||
| int | nkey, | ||
| const void * | value, | ||
| int | nvalue ) |
Inserts a new value with given key into the hash table.
| [in] | t | A pointer to a hashTable_s structure. |
| [in] | key | A pointer to a key. |
| [in] | nkey | The length of the key value in bytes. |
| [in] | value | A pointer to a value. |
| [in] | nvalue | The length of the value in bytes. |
Definition at line 369 of file hashtable.cpp.
References _find_bucket_entry(), _hash_alloc(), hashTable_s::compare, hashBucket_s::count, hashTable_s::duplicateOverwrite, hashTable_s::hash, i, hashTable_s::internalPool, key, hashTable_s::keyPool, hashTable_s::ownsKeys, hashTable_s::ownsValues, hashBucket_s::root, hashTable_s::table, and hashTable_s::valuePool.
Referenced by CL_RegisterCallback(), HASH_CloneTable(), UI_AddBehaviourMethod(), and UI_AddNodeMethod().
| hashTable_s * HASH_NewTable | ( | bool | ownsKeys, |
| bool | ownsValues, | ||
| bool | duplicateOverwrite ) |
Creates a new hash table and sets it initial capacity.
| [in] | ownsKeys | If true, the hash table stores a copy of the key. |
| [in] | ownsValues | If true, the hash table stores a copy of the value. |
| [in] | duplicateOverwrite | If true, inserting a value twice will overwrite the old value. If false, the operation asserts. |
Definition at line 287 of file hashtable.cpp.
References default_compare(), default_hash(), and HASH_NewTable().
Referenced by CL_InitLua(), HASH_CloneTable(), HASH_NewTable(), HASH_NewTable(), UI_AddBehaviourMethod(), and UI_AddNodeMethod().
| hashTable_s * HASH_NewTable | ( | bool | ownsKeys, |
| bool | ownsValues, | ||
| bool | duplicateOverwrite, | ||
| hashTable_hash | h, | ||
| hashTable_compare | c ) |
Creates a new hash table and sets it initial capacity.
| [in] | ownsKeys | If true, the hash table stores a copy of the key. |
| [in] | ownsValues | If true, the hash table stores a copy of the value. |
| [in] | duplicateOverwrite | If true, inserting a value twice will overwrite the old value. If false, the operation asserts. |
| [in] | h | The hash function to be used when indexing. |
| [in] | c | The compare function to be used when comparing. |
Definition at line 303 of file hashtable.cpp.
References HASH_NewTable().
| hashTable_s * HASH_NewTable | ( | bool | ownsKeys, |
| bool | ownsValues, | ||
| bool | duplicateOverwrite, | ||
| hashTable_hash | h, | ||
| hashTable_compare | c, | ||
| memPool_t * | keys, | ||
| memPool_t * | values, | ||
| memPool_t * | table ) |
Creates a new hash table and sets it initial capacity.
| [in] | ownsKeys | If true, the hash table stores a copy of the key. |
| [in] | ownsValues | If true, the hash table stores a copy of the value. |
| [in] | duplicateOverwrite | If true, inserting a value twice will overwrite the old value. If false, the operation asserts. |
| [in] | h | The hash function to be used when indexing. |
| [in] | c | The compare function to be used when comparing. |
| [in] | keys | If not null, should point to a memory pool used to allocate key values. |
| [in] | values | If not null, should point to a memory pool used to allocated copies of inserted values. |
| [in] | table | If not null, should point to a memory pool used to allocate the table internal structures, including the hashTable_s structure returned. |
Definition at line 322 of file hashtable.cpp.
References _hash_alloc(), hashTable_s::compare, hashTable_s::duplicateOverwrite, hashTable_s::hash, hashTable_s::internalPool, hashTable_s::keyPool, hashTable_s::ownsKeys, hashTable_s::ownsValues, and hashTable_s::valuePool.
| void * HASH_Remove | ( | hashTable_s * | t, |
| const void * | key, | ||
| int | nkey ) |
Removes an existing value with given key from the hash table.
Definition at line 429 of file hashtable.cpp.
References _find_bucket_entry(), _release_entry(), hashTable_s::compare, hashBucket_s::count, hashTable_s::hash, i, key, hashItem_s::next, hashTable_s::ownsKeys, hashTable_s::ownsValues, hashBucket_s::root, hashTable_s::table, and v.