CMR  1.3.0
Classes | Typedefs | Functions
hashtable.c File Reference
#include "hashtable.h"
#include <stdio.h>
#include <limits.h>
#include <assert.h>
#include <stdlib.h>
#include <stdint.h>
#include "env_internal.h"

Classes

struct  LinearhashtableArrayBucket
 
struct  _CMR_LINEARHASHTABLE_ARRAY
 
struct  ListhashtableNode
 
struct  _CMR_LISTHASHTABLE
 

Typedefs

typedef ListhashtableNode_CMR_LISTHASHTABLE_NODE
 

Functions

static size_t linearhashtableArrayHashToBucket (CMR_LINEARHASHTABLE_ARRAY *hashtable, CMR_LINEARHASHTABLE_HASH hash)
 
CMR_ERROR CMRlinearhashtableArrayCreate (CMR *cmr, CMR_LINEARHASHTABLE_ARRAY **phashtable, size_t initialSize, size_t initialKeyMemory)
 
CMR_ERROR CMRlinearhashtableArrayFree (CMR *cmr, CMR_LINEARHASHTABLE_ARRAY **phashtable)
 
const void * CMRlinearhashtableArrayKey (CMR_LINEARHASHTABLE_ARRAY *hashtable, CMR_LINEARHASHTABLE_HASH hash, size_t *pKeyLength)
 
const void * CMRlinearhashtableArrayValue (CMR_LINEARHASHTABLE_ARRAY *hashtable, CMR_LINEARHASHTABLE_HASH hash)
 
bool CMRlinearhashtableArrayFind (CMR_LINEARHASHTABLE_ARRAY *hashtable, const void *keyArray, size_t keyLength, CMR_LINEARHASHTABLE_BUCKET *pbucket, CMR_LINEARHASHTABLE_HASH *phash)
 
CMR_ERROR CMRlinearhashtableArrayInsertBucketHash (CMR *cmr, CMR_LINEARHASHTABLE_ARRAY *hashtable, const void *keyArray, size_t keyLength, CMR_LINEARHASHTABLE_BUCKET bucket, CMR_LINEARHASHTABLE_HASH hash, const void *value)
 
CMR_ERROR CMRlinearhashtableArrayInsert (CMR *cmr, CMR_LINEARHASHTABLE_ARRAY *hashtable, const void *keyArray, size_t keyLength, const void *value)
 
CMR_ERROR CMRlisthashtableCreate (CMR *cmr, CMR_LISTHASHTABLE **phashtable, size_t initialNumBuckets, size_t initialMemNodes)
 
CMR_ERROR CMRlisthashtableFree (CMR *cmr, CMR_LISTHASHTABLE **phashtable)
 
static CMR_LISTHASHTABLE_BUCKET listhashtableHashToBucket (CMR_LISTHASHTABLE *hashtable, CMR_LISTHASHTABLE_HASH hash)
 
CMR_LISTHASHTABLE_ENTRY CMRlisthashtableFindFirst (CMR_LISTHASHTABLE *hashtable, CMR_LISTHASHTABLE_HASH hash)
 
CMR_LISTHASHTABLE_ENTRY CMRlisthashtableFindNext (CMR_LISTHASHTABLE *hashtable, CMR_LISTHASHTABLE_HASH hash, CMR_LISTHASHTABLE_ENTRY entry)
 
CMR_LISTHASHTABLE_VALUE CMRlisthashtableValue (CMR_LISTHASHTABLE *hashtable, CMR_LISTHASHTABLE_ENTRY entry)
 
CMR_LISTHASHTABLE_HASH CMRlisthashtableHash (CMR_LISTHASHTABLE *hashtable, CMR_LISTHASHTABLE_ENTRY entry)
 
size_t CMRlisthashtableNumBuckets (CMR_LISTHASHTABLE *hashtable)
 
CMR_ERROR CMRlisthashtableInsert (CMR *cmr, CMR_LISTHASHTABLE *hashtable, CMR_LISTHASHTABLE_HASH hash, CMR_LISTHASHTABLE_VALUE value, CMR_LISTHASHTABLE_ENTRY *pentry)
 Inserts value with hash into the hash table, even if an entry with the same hash exists. More...
 
CMR_ERROR CMRlisthashtableRemove (CMR *cmr, CMR_LISTHASHTABLE *hashtable, CMR_LISTHASHTABLE_ENTRY entry)
 

Typedef Documentation

Function Documentation

CMR_ERROR CMRlinearhashtableArrayCreate ( CMR cmr,
CMR_LINEARHASHTABLE_ARRAY **  phashtable,
size_t  initialSize,
size_t  initialKeyMemory 
)
Parameters
cmrCMR environment.
phashtablePointer for storing the hash table.
initialSizeInitial size of hash table.
initialKeyMemoryInitial memory for keys.
bool CMRlinearhashtableArrayFind ( CMR_LINEARHASHTABLE_ARRAY hashtable,
const void *  keyArray,
size_t  keyLength,
CMR_LINEARHASHTABLE_BUCKET pbucket,
CMR_LINEARHASHTABLE_HASH phash 
)
Parameters
hashtableHash table.
keyArrayFirst byte of key array.
keyLengthLength of key array in bytes.
pbucketPointer for storing the bucket.
phashPointer for storing the hash.
CMR_ERROR CMRlinearhashtableArrayFree ( CMR cmr,
CMR_LINEARHASHTABLE_ARRAY **  phashtable 
)
Parameters
cmrCMR environment.
phashtablePointer to the hash table.
CMR_ERROR CMRlinearhashtableArrayInsert ( CMR cmr,
CMR_LINEARHASHTABLE_ARRAY hashtable,
const void *  keyArray,
size_t  keyLength,
const void *  value 
)
Parameters
cmrCMR environment.
hashtableHash table.
keyArrayFirst byte of key array.
keyLengthLength of key array.
valueValue to be set.
CMR_ERROR CMRlinearhashtableArrayInsertBucketHash ( CMR cmr,
CMR_LINEARHASHTABLE_ARRAY hashtable,
const void *  keyArray,
size_t  keyLength,
CMR_LINEARHASHTABLE_BUCKET  bucket,
CMR_LINEARHASHTABLE_HASH  hash,
const void *  value 
)
Parameters
cmrCMR environment.
hashtableHash table.
keyArrayFirst byte of key array.
keyLengthLength of key array.
bucketKnown bucket of key, determined by CMRlinearhashtableArrayFind.
hashKnown hash of key, determined by CMRlinearhashtableArrayFind.
valueValue to be set.
const void* CMRlinearhashtableArrayKey ( CMR_LINEARHASHTABLE_ARRAY hashtable,
CMR_LINEARHASHTABLE_HASH  hash,
size_t *  pKeyLength 
)
Parameters
hashtableHash table.
hashBucket.
pKeyLengthLength of key array.
const void* CMRlinearhashtableArrayValue ( CMR_LINEARHASHTABLE_ARRAY hashtable,
CMR_LINEARHASHTABLE_HASH  hash 
)
Parameters
hashtableHash table.
hashBucket.
CMR_ERROR CMRlisthashtableCreate ( CMR cmr,
CMR_LISTHASHTABLE **  phashtable,
size_t  initialNumBuckets,
size_t  initialMemNodes 
)
Parameters
cmrCMR environment.
phashtablePointer for storing the hash table.
initialNumBucketsInitial size of hash table.
initialMemNodesInitial memory for actual entries..
CMR_LISTHASHTABLE_ENTRY CMRlisthashtableFindFirst ( CMR_LISTHASHTABLE hashtable,
CMR_LISTHASHTABLE_HASH  hash 
)
Parameters
hashtableHash table.
hashHash value.
CMR_LISTHASHTABLE_ENTRY CMRlisthashtableFindNext ( CMR_LISTHASHTABLE hashtable,
CMR_LISTHASHTABLE_HASH  hash,
CMR_LISTHASHTABLE_ENTRY  entry 
)
Parameters
hashtableHash table.
hashHash value.
entryCurrent entry.
CMR_ERROR CMRlisthashtableFree ( CMR cmr,
CMR_LISTHASHTABLE **  phashtable 
)
Parameters
cmrCMR environment.
phashtablePointer to the hash table.
CMR_LISTHASHTABLE_HASH CMRlisthashtableHash ( CMR_LISTHASHTABLE hashtable,
CMR_LISTHASHTABLE_ENTRY  entry 
)
Parameters
hashtableHash table.
entryEntry.
CMR_ERROR CMRlisthashtableInsert ( CMR cmr,
CMR_LISTHASHTABLE hashtable,
CMR_LISTHASHTABLE_HASH  hash,
CMR_LISTHASHTABLE_VALUE  value,
CMR_LISTHASHTABLE_ENTRY pentry 
)

Inserts value with hash into the hash table, even if an entry with the same hash exists.

Parameters
cmrCMR environment.
hashtableHash table.
hashHash value.
valueValue to be set.
pentryPointer for storing the new entry.
size_t CMRlisthashtableNumBuckets ( CMR_LISTHASHTABLE hashtable)
Parameters
hashtableHash table.
CMR_ERROR CMRlisthashtableRemove ( CMR cmr,
CMR_LISTHASHTABLE hashtable,
CMR_LISTHASHTABLE_ENTRY  entry 
)
Parameters
cmrCMR environment.
hashtableHash table.
entryEntry to be removed.
CMR_LISTHASHTABLE_VALUE CMRlisthashtableValue ( CMR_LISTHASHTABLE hashtable,
CMR_LISTHASHTABLE_ENTRY  entry 
)
Parameters
hashtableHash table.
entryEntry.
static size_t linearhashtableArrayHashToBucket ( CMR_LINEARHASHTABLE_ARRAY hashtable,
CMR_LINEARHASHTABLE_HASH  hash 
)
inlinestatic
static CMR_LISTHASHTABLE_BUCKET listhashtableHashToBucket ( CMR_LISTHASHTABLE hashtable,
CMR_LISTHASHTABLE_HASH  hash 
)
inlinestatic