Main Page   Modules   Compound List   File List   Compound Members   File Members   Related Pages  

lib/hash.h File Reference

Hash table implemenation. More...

Go to the source code of this file.

Typedefs

typedef struct hashTable_shashTable
typedef unsigned int (* hashFunctionType )(const void *string)
typedef int (* hashEqualityType )(const void *key1, const void *key2)

Functions

unsigned int hashFunctionString (const void *string)
 Return hash value of a string. More...

int hashEqualityString (const void *key1, const void *key2)
 Compare two hash table entries for equality. More...

hashTable htCreate (int numBuckets, int keySize, int freeData, hashFunctionType fn, hashEqualityType eq)
 Create hash table. More...

void htFree (hashTable ht)
 Destroy hash table. More...

void htAddEntry (hashTable ht, const void *key, const void *data)
 Add item to hash table. More...

int htGetEntry (hashTable ht, const void *key, const void ***data, int *dataCount, const void **tableKey)
 Retrieve item from hash table. More...

int htHasEntry (hashTable ht, const void *key)
 Check for key in hash table. More...


Detailed Description

Hash table implemenation.

Definition in file hash.h.


Typedef Documentation

typedef int(* hashEqualityType)(const void *key1, const void *key2)
 

Definition at line 17 of file hash.h.

typedef unsigned int(* hashFunctionType)(const void *string)
 

Definition at line 15 of file hash.h.

typedef struct hashTable_s* hashTable
 

Definition at line 8 of file hash.h.


Function Documentation

int hashEqualityString ( const void * key1,
const void * key2 )
 

Compare two hash table entries for equality.

Parameters:
key1   entry 1
key2   entry 2
Returns:
0 if entries are equal

Definition at line 51 of file hash.c.

unsigned int hashFunctionString ( const void * string )
 

Return hash value of a string.

Parameters:
string   string on which to calculate hash value
Returns:
hash value

Definition at line 58 of file hash.c.

void htAddEntry ( hashTable ht,
const void * key,
const void * data )
 

Add item to hash table.

Parameters:
ht   pointer to hash table
key   pointer to key
data   pointer to data value

Definition at line 91 of file hash.c.

Referenced by doLookup(), and rpmRunTransactions().

hashTable htCreate ( int numBuckets,
int keySize,
int freeData,
hashFunctionType fn,
hashEqualityType eq )
 

Create hash table.

If keySize > 0, the key is duplicated within the table (which costs memory, but may be useful anyway.

Parameters:
numBuckets   number of hash buckets
keySize   size of key (0 if unknown)
freeData   should data be freed when table is destroyed?
fn   function to generate hash value for key
eq   function to compare hash keys for equality
Returns:
pointer to initialized hash table

Definition at line 75 of file hash.c.

Referenced by fpCacheCreate(), and rpmRunTransactions().

void htFree ( hashTable ht )
 

Destroy hash table.

Parameters:
ht   pointer to hash table

Definition at line 121 of file hash.c.

Referenced by fpCacheFree(), and rpmRunTransactions().

int htGetEntry ( hashTable ht,
const void * key,
const void *** data,
int * dataCount,
const void ** tableKey )
 

Retrieve item from hash table.

Parameters:
ht   pointer to hash table
key   pointer to key value
Return values:
data   address to store data value from bucket
dataCount   address to store data value size from bucket
tableKey   address to store key value from bucket (may be NULL)
Returns:
0 on success, 1 if the item is not found.

Definition at line 151 of file hash.c.

Referenced by cacheContainsDirectory(), and handleOverlappedFiles().

int htHasEntry ( hashTable ht,
const void * key )
 

Check for key in hash table.

Parameters:
ht   pointer to hash table
key   pointer to key value
Returns:
1 if the key is present, 0 otherwise

Definition at line 144 of file hash.c.


Generated at Mon May 21 08:53:42 2001 for rpm by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001