-HashNode* HT_Find (const HashTable* T, const void* Index)
+HashNode* HT_Find (const HashTable* T, const void* Key)
/* Find the node with the given index */
{
unsigned Hash;
}
/* Generate the hash over the index */
- Hash = T->Func->GenHash (Index);
+ Hash = T->Func->GenHash (Key);
/* Search for the entry in the given chain */
N = T->Table[Hash % T->Slots];
* if it is not really necessary.
*/
if (N->Hash == Hash &&
- T->Func->Compare (Index, T->Func->GetIndex (N->Entry))) {
+ T->Func->Compare (Key, T->Func->GetIndex (N->Entry))) {
/* Found */
break;
}
-void* HT_FindEntry (const HashTable* T, const void* Index)
+void* HT_FindEntry (const HashTable* T, const void* Key)
/* Find the node with the given index and return the corresponding entry */
{
/* First, search for the hash node */
- HashNode* N = HT_Find (T, Index);
+ HashNode* N = HT_Find (T, Key);
/* Convert the node into an entry if necessary */
return N? N->Entry : 0;
typedef struct HashFunctions HashFunctions;
struct HashFunctions {
- unsigned (*GenHash) (const void* Index);
- /* Generate the hash over an index. */
+ unsigned (*GenHash) (const void* Key);
+ /* Generate the hash over a key. */
const void* (*GetIndex) (void* Entry);
/* Given a pointer to the user entry data, return a pointer to the index */
HashNode* (*GetHashNode) (void* Entry);
/* Given a pointer to the user entry data, return a pointer to the hash node */
- int (*Compare) (const void* Index1, const void* Index2);
- /* Compare two indices for equality */
+ int (*Compare) (const void* Key1, const void* Key2);
+ /* Compare two keys for equality */
};
/* Hash table */
void FreeHashTable (HashTable* T);
/* Free a hash table. Note: This will not free the entries in the table! */
-HashNode* HT_Find (const HashTable* T, const void* Index);
-/* Find the node with the given index */
+HashNode* HT_Find (const HashTable* T, const void* Key);
+/* Find the node with the given key*/
-void* HT_FindEntry (const HashTable* T, const void* Index);
-/* Find the node with the given index and return the corresponding entry */
+void* HT_FindEntry (const HashTable* T, const void* Key);
+/* Find the node with the given key and return the corresponding entry */
void HT_Insert (HashTable* T, HashNode* N);
/* Insert a node into the given hash table */