hash.h File Reference

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)
HashMaphash_new ()

Variables

static const unsigned int primes []

Define Documentation

#define HASH_ACTIVE   0x00000001

Definition at line 8 of file hash.h.

Referenced by hash_delete(), hash_get(), hash_insert(), and hash_recalc().

#define HASH_DEAD   0x00000000

Definition at line 7 of file hash.h.


Function Documentation

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.

Parameters:
cur (int) The current prime number
Returns:
(int) prime number or 0 if we have reached the end of the list.

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.

Parameters:
hash (HashMap) hash map we are inspecting.
Returns:
(long) entry count.

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.

Parameters:
hash (HashMap) hash we are deleting from our hash.
key (char) - key to the map entry we are deleting.
Returns:
Nothing yet again.

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

Parameters:
hash (HashMap) hash map we are freeing
Returns:
NOTHING ok? thanks...

Definition at line 158 of file hash.c.

References HashMap::table.

void* hash_get ( HashMap hash,
char *  key 
)
int hash_insert ( HashMap hash,
long  key,
void *  data 
)

hash_insert - Insert a hash entry into our hash map.

Parameters:
hash (HashMap) Pointer to our current hashmap.
key (long) Non hashed string value of our key.
data (void*) Data to be placed into key
Returns:
(bool) 1 on success and 0 on fail.

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.

Returns:
HashMap* - pointer to the newly created hash

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

Parameters:
hash (HashMap) pointer to the hash we are resizeing
Returns:
(bool) 1 on success and 0 on fail.

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().


Variable Documentation

const unsigned int primes[] [static]
Initial value:
 {
        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().

Generated on Mon Jul 19 21:53:05 2010 for Omega Security Services by  doxygen 1.6.3