|
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) |
|
Piojo Hash Table implementation.
Allocates a new hash table.
- Parameters
-
[in] | evsize | Entry value size in bytes. |
[in] | keyeq | Entry key equality function. |
[in] | eksize | Entry key size in bytes. |
[in] | allocator | Allocator 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] | evsize | Entry value size in bytes. |
[in] | allocator | Allocator 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] | evsize | Entry value size in bytes. |
[in] | allocator | Allocator 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] | evsize | Entry value size in bytes. |
[in] | allocator | Allocator 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] | evsize | Entry value size in bytes. |
[in] | keyeq | Entry key equality function. |
[in] | eksize | Entry 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] | evsize | Entry 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] | evsize | Entry 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] | evsize | Entry value size in bytes. |
- Returns
- New hash table.
void piojo_hash_clear |
( |
piojo_hash_t * |
hash | ) |
|
Deletes all entries in hash.
- Parameters
-
[out] | hash | Hash table being cleared. |
piojo_hash_t* piojo_hash_copy |
( |
const piojo_hash_t * |
hash | ) |
|
Copies hash and all its entries.
- Parameters
-
[in] | hash | Hash table being copied. |
- Returns
- New hash.
bool piojo_hash_delete |
( |
const void * |
key, |
|
|
piojo_hash_t * |
hash |
|
) |
| |
Deletes an entry by key.
- Parameters
-
[in] | key | Entry key. |
[out] | hash | Hash 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] | hash | Hash table. |
[out] | data | Entry 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] | hash | Hash 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] | key | Entry key. |
[in] | data | Entry value. |
[out] | hash | Hash 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] | hash | Hash table. |
[out] | data | Entry 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] | key | Entry key. |
[in] | hash | Hash 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] | key | Entry key. |
[in] | data | Entry value. |
[out] | hash | Hash 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
-
- Returns
- Number of entries in hash.
const size_t piojo_hash_sizeof |
Size of hash table in bytes