Main Page | Modules | Data Structures | File List | Globals | Related Pages

HashTable.h File Reference


Detailed Description

A hash table.

Thanks:
to Chun-Hsiang Hung for implementing the HashTable ADT.

Wish List:
A cleaner hash table interface (without the compare function). I think that the sprint learner is the only thing that uses this currently so there isn't much to change to fix this.

Go to the source code of this file.

Data Structures

struct  HashTable
 A hash table ADT. More...


Functions

HashTableHashTableNew (int size)
 Creates a new hash table with the specified number of entries.

void HashTableInsert (HashTable *table, int index, void *element)
 Inserts the element into the has table at the appropriate place.

void * HashTableFind (HashTable *table, int index, int(*cmp)(const void *, const int))
 Looks up index in the hash table.

void HashTableFree (HashTable *table)
 Frees the memory being used by the hash table.

void * HashTableRemove (HashTable *table, int index, int(*cmp)(const void *, const int))
 Removes the element from the hash table.


Function Documentation

void* HashTableFind HashTable table,
int  index,
int(*  cmp)(const void *, const int)
 

Looks up index in the hash table.

Not only must you use the same index, but you must also supply a function that returns non-zero when passed the element you want to find and the index (which you passed to the function in the first place...)

void HashTableFree HashTable table  ) 
 

Frees the memory being used by the hash table.

But doesn't touch the memory being used by the elements in the table. It is your responsibility to free these if you like.

void HashTableInsert HashTable table,
int  index,
void *  element
 

Inserts the element into the has table at the appropriate place.

HashTable* HashTableNew int  size  ) 
 

Creates a new hash table with the specified number of entries.

void* HashTableRemove HashTable table,
int  index,
int(*  cmp)(const void *, const int)
 

Removes the element from the hash table.

Not only must you use the same index, but you must also supply a function that returns non-zero when passed the element you want to find and the index (which you passed to the function in the first place...)


Generated for VFML by doxygen hosted by SourceForge.net Logo