Go to the source code of this file.
Data Structures | |
| struct | HashEntry |
| struct | HashMap |
Defines | |
| #define | HASH_DEAD 0x00000000 |
| #define | HASH_ACTIVE 0x00000001 |
Functions | |
| void * | hash_get (HashMap *hash, char *key) |
| void | hash_delete (HashMap *hash, char *key) |
| void | hash_free (HashMap *hash) |
| long | hash_count (HashMap *hash) |
| int | get_next_prime (int cur) |
| int | hash_recalc (HashMap *hash) |
| int | hash_insert (HashMap *hash, long key, void *data) |
| HashMap * | hash_new () |
Variables | |
| static const unsigned int | primes [] |
| #define HASH_ACTIVE 0x00000001 |
Definition at line 8 of file hash.h.
Referenced by hash_delete(), hash_get(), hash_insert(), and hash_recalc().
| int get_next_prime | ( | int | cur | ) |
get_next_prime - return the next prime number in our series of primes or 0 if we reached the end of our lists.
| cur | (int) The current prime number |
Definition at line 126 of file hash.c.
References primes.
Referenced by hash_recalc().
| long hash_count | ( | HashMap * | hash | ) |
hash_count - Return the numbers of entries in a hashmap.
| hash | (HashMap) hash map we are inspecting. |
Definition at line 146 of file hash.c.
References HashMap::count.
| void hash_delete | ( | HashMap * | hash, | |
| char * | key | |||
| ) |
hash_delete - Remove an item from the hash map.
| hash | (HashMap) hash we are deleting from our hash. | |
| key | (char) - key to the map entry we are deleting. |
Definition at line 175 of file hash.c.
References HashMap::count, HashEntry::flags, HASH, HASH_ACTIVE, HashEntry::key, HashMap::size, and HashMap::table.
| void hash_free | ( | HashMap * | hash | ) |
hash_free - free out a hash map
| hash | (HashMap) hash map we are freeing |
Definition at line 158 of file hash.c.
References HashMap::table.
| void* hash_get | ( | HashMap * | hash, | |
| char * | key | |||
| ) |
Definition at line 199 of file hash.c.
References HashEntry::data, HashEntry::flags, HASH, HASH_ACTIVE, HashEntry::key, HashMap::size, and HashMap::table.
| int hash_insert | ( | HashMap * | hash, | |
| long | key, | |||
| void * | data | |||
| ) |
hash_insert - Insert a hash entry into our hash map.
| hash | (HashMap) Pointer to our current hashmap. | |
| key | (long) Non hashed string value of our key. | |
| data | (void*) Data to be placed into key |
Definition at line 44 of file hash.c.
References HashMap::count, HashEntry::data, HashEntry::flags, HASH_ACTIVE, hash_new(), hash_recalc(), HashEntry::key, HashMap::size, and HashMap::table.
Referenced by hash_recalc().
| HashMap* hash_new | ( | ) |
hash_new - Create a new hash map and return a pointer to it. calculate the smallest possible size first, then we can recaculate it from there.
Definition at line 20 of file hash.c.
References HashMap::count, primes, HashMap::size, and HashMap::table.
Referenced by hash_insert().
| int hash_recalc | ( | HashMap * | hash | ) |
hash_recalc - recaculate the size of our hash table
| hash | (HashMap) pointer to the hash we are resizeing |
Definition at line 91 of file hash.c.
References HashMap::count, get_next_prime(), HASH_ACTIVE, hash_insert(), HashMap::size, and HashMap::table.
Referenced by hash_insert().
const unsigned int primes[] [static] |
{
53, 97,
193, 389,
769, 1543,
3079, 6151,
12289, 24593,
49157, 98317,
196613, 393241,
786433, 1572869,
3145739, 6291469,
12582917, 25165843,
50331653, 100663319,
201326611, 402653189,
805306457, 1610612741
}
Definition at line 23 of file hash.h.
Referenced by get_next_prime(), and hash_new().
1.6.3