piojo-0.9
 All Classes Functions Variables Typedefs Enumerations Enumerator Groups
Piojo Hash Table

Functions

piojo_hash_t * piojo_hash_alloc_i32k (size_t evsize)
 
piojo_hash_t * piojo_hash_alloc_i64k (size_t evsize)
 
piojo_hash_t * piojo_hash_alloc_sizk (size_t evsize)
 
piojo_hash_t * piojo_hash_alloc_cb_i32k (size_t evsize, piojo_alloc_if allocator)
 
piojo_hash_t * piojo_hash_alloc_cb_i64k (size_t evsize, piojo_alloc_if allocator)
 
piojo_hash_t * piojo_hash_alloc_cb_sizk (size_t evsize, piojo_alloc_if allocator)
 
piojo_hash_t * piojo_hash_alloc_eq (size_t evsize, piojo_eq_cb keyeq, size_t eksize)
 
piojo_hash_t * piojo_hash_alloc_cb_eq (size_t evsize, piojo_eq_cb keyeq, size_t eksize, piojo_alloc_if allocator)
 
piojo_hash_t * piojo_hash_copy (const piojo_hash_t *hash)
 
void piojo_hash_free (const piojo_hash_t *hash)
 
void piojo_hash_clear (piojo_hash_t *hash)
 
size_t piojo_hash_size (const piojo_hash_t *hash)
 
bool piojo_hash_insert (const void *key, const void *data, piojo_hash_t *hash)
 
bool piojo_hash_set (const void *key, const void *data, piojo_hash_t *hash)
 
void * piojo_hash_search (const void *key, const piojo_hash_t *hash)
 
bool piojo_hash_delete (const void *key, piojo_hash_t *hash)
 
const void * piojo_hash_first (const piojo_hash_t *hash, void **data)
 
const void * piojo_hash_next (const void *key, const piojo_hash_t *hash, void **data)
 

Variables

const size_t piojo_hash_sizeof
 

Detailed Description

Piojo Hash Table implementation.

Function Documentation

piojo_hash_t* piojo_hash_alloc_cb_eq ( size_t  evsize,
piojo_eq_cb  keyeq,
size_t  eksize,
piojo_alloc_if  allocator 
)

Allocates a new hash table.

Parameters
[in]evsizeEntry value size in bytes.
[in]keyeqEntry key equality function.
[in]eksizeEntry key size in bytes.
[in]allocatorAllocator to be used.
Returns
New hash table.
piojo_hash_t* piojo_hash_alloc_cb_i32k ( size_t  evsize,
piojo_alloc_if  allocator 
)

Allocates a new hash table. Uses key size of int32_t.

Parameters
[in]evsizeEntry value size in bytes.
[in]allocatorAllocator to be used.
Returns
New hash table.
piojo_hash_t* piojo_hash_alloc_cb_i64k ( size_t  evsize,
piojo_alloc_if  allocator 
)

Allocates a new hash table. Uses key size of int64_t.

Parameters
[in]evsizeEntry value size in bytes.
[in]allocatorAllocator to be used.
Returns
New hash table.
piojo_hash_t* piojo_hash_alloc_cb_sizk ( size_t  evsize,
piojo_alloc_if  allocator 
)

Allocates a new hash table. Uses key size of size_t.

Parameters
[in]evsizeEntry value size in bytes.
[in]allocatorAllocator to be used.
Returns
New hash table.
piojo_hash_t* piojo_hash_alloc_eq ( size_t  evsize,
piojo_eq_cb  keyeq,
size_t  eksize 
)

Allocates a new hash table. Uses default allocator.

Parameters
[in]evsizeEntry value size in bytes.
[in]keyeqEntry key equality function.
[in]eksizeEntry key size in bytes.
Returns
New hash table.
piojo_hash_t* piojo_hash_alloc_i32k ( size_t  evsize)

Allocates a new hash table. Uses default allocator and key size of int32_t.

Parameters
[in]evsizeEntry value size in bytes.
Returns
New hash table.
piojo_hash_t* piojo_hash_alloc_i64k ( size_t  evsize)

Allocates a new hash table. Uses default allocator and key size of int64_t.

Parameters
[in]evsizeEntry value size in bytes.
Returns
New hash table.
piojo_hash_t* piojo_hash_alloc_sizk ( size_t  evsize)

Allocates a new hash table. Uses default allocator and key size of size_t.

Parameters
[in]evsizeEntry value size in bytes.
Returns
New hash table.
void piojo_hash_clear ( piojo_hash_t *  hash)

Deletes all entries in hash.

Parameters
[out]hashHash table being cleared.
piojo_hash_t* piojo_hash_copy ( const piojo_hash_t *  hash)

Copies hash and all its entries.

Parameters
[in]hashHash table being copied.
Returns
New hash.
bool piojo_hash_delete ( const void *  key,
piojo_hash_t *  hash 
)

Deletes an entry by key.

Parameters
[in]keyEntry key.
[out]hashHash table.
Returns
TRUE if deleted, FALSE if key doesn't exist.
const void* piojo_hash_first ( const piojo_hash_t *  hash,
void **  data 
)

Reads the first entry in hash.

Parameters
[in]hashHash table.
[out]dataEntry value, can be NULL.
Returns
first key or NULL if hash is empty.
void piojo_hash_free ( const piojo_hash_t *  hash)

Frees hash and all its entries.

Parameters
[in]hashHash table being freed.
bool piojo_hash_insert ( const void *  key,
const void *  data,
piojo_hash_t *  hash 
)

Inserts a new entry. If data is NULL, the value is replaced with TRUE (useful for sets).

Parameters
[in]keyEntry key.
[in]dataEntry value.
[out]hashHash table being modified.
Returns
TRUE if inserted, FALSE if key is duplicate.
const void* piojo_hash_next ( const void *  key,
const piojo_hash_t *  hash,
void **  data 
)

Reads the next entry.

Parameters
[in]key
[in]hashHash table.
[out]dataEntry value, can be NULL.
Returns
next key or NULL if key is the last one.
void* piojo_hash_search ( const void *  key,
const piojo_hash_t *  hash 
)

Searches an entry by key.

Parameters
[in]keyEntry key.
[in]hashHash table.
Returns
Entry value or NULL if key doesn't exist.
bool piojo_hash_set ( const void *  key,
const void *  data,
piojo_hash_t *  hash 
)

Replaces or inserts an entry. If data is NULL, the value is replaced with TRUE (useful for sets).

Parameters
[in]keyEntry key.
[in]dataEntry value.
[out]hashHash table being modified.
Returns
TRUE if key is new, FALSE otherwise.
size_t piojo_hash_size ( const piojo_hash_t *  hash)

Returns number of entries.

Parameters
[in]hashHash table
Returns
Number of entries in hash.

Variable Documentation

const size_t piojo_hash_sizeof

Size of hash table in bytes