Skip to content

Instantly share code, notes, and snippets.

@zhuowei
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zhuowei/9533905 to your computer and use it in GitHub Desktop.
Save zhuowei/9533905 to your computer and use it in GitHub Desktop.
HashTable header, copied in
typedef struct HashTableObjectTag HashTableObject;
typedef HashTableObject *HashTablePTR;
typedef struct HashTableInfoTag
{
unsigned int bucketCount; // current number of buckets
float loadFactor; // ( number of entries / number of buckets )
float useFactor; // ( number of buckets with one or more entries / number of buckets )
unsigned int largestBucketSize; // number of entries in the bucket containing the most entries
int dynamicBehaviour; // whether or not the Hash Table will resize dynamically
float expandUseFactor; // the value of useFactor that will trigger an expansion of the number of buckets
float contractUseFactor; // the value of useFactor that will trigger a contraction in the number of buckets
} HashTableInfo;
int CreateHashTable( HashTablePTR *hashTableHandle, unsigned int initialSize );
int DestroyHashTable( HashTablePTR *hashTableHandle );
int InsertEntry( HashTablePTR hashTable, char *key, void *data, void **existingDataHandle );
int DeleteEntry( HashTablePTR hashTable, char *key, void **data );
int FindEntry( HashTablePTR hashTable, char *key, void **data );
int GetKeys( HashTablePTR hashTable, char ***keys, unsigned int *keyCount );
int GetLoadFactor( HashTablePTR hashTable, float *loadFactor );
int GetHashTableInfo( HashTablePTR hashTable, HashTableInfo *pHashTableInfo );
int SetResizeBehaviour( HashTablePTR hashTable, int dynamicBehaviour, float expandUseFactor, float contractUseFactor );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment