|
libcute 0.1
|
#include "hash/hash.h"#include "macro.h"#include "memory/allocator.h"#include "object/optional.h"#include "object/result.h"#include "state.h"#include "utility.h"#include <stdbool.h>#include <stddef.h>

Go to the source code of this file.
Classes | |
| struct | cu_HashMap_Bucket |
| struct | cu_HashMap |
Typedefs | |
| typedef uint64_t(* | cu_HashMap_HashFn) (const void *key, size_t key_size) |
| typedef bool(* | cu_HashMap_EqualsFn) (const void *a, const void *b, size_t key_size) |
Enumerations | |
| enum | cu_HashMap_Error { CU_HASHMAP_ERROR_NONE = 0 , CU_HASHMAP_ERROR_OOM , CU_HASHMAP_ERROR_INVALID_LAYOUT , CU_HASHMAP_ERROR_INVALID } |
Functions | |
| cu_HashMap_Result | cu_HashMap_create (cu_Allocator allocator, cu_Layout key_layout, cu_Layout value_layout, Size_Optional initial_capacity, cu_HashMap_HashFn_Optional hash_fn, cu_HashMap_EqualsFn_Optional equals_fn, cu_State state) |
| Create a new hashmap. | |
| void | cu_HashMap_destroy (cu_HashMap *map) |
| cu_HashMap_Error_Optional | cu_HashMap_insert (cu_HashMap *map, void *key, void *value) |
| Insert a new key-value pair. | |
| Ptr_Optional | cu_HashMap_get (const cu_HashMap *map, const void *key) |
Retrieve the value stored for key. | |
| bool | cu_HashMap_iter (const cu_HashMap *map, size_t *index, void **key, void **value) |
| Iterate over all stored pairs. | |
Simple hashmap container.
| enum cu_HashMap_Error |
Possible error codes returned by hashmap operations.
| cu_HashMap_Result cu_HashMap_create | ( | cu_Allocator | allocator, |
| cu_Layout | key_layout, | ||
| cu_Layout | value_layout, | ||
| Size_Optional | initial_capacity, | ||
| cu_HashMap_HashFn_Optional | hash_fn, | ||
| cu_HashMap_EqualsFn_Optional | equals_fn, | ||
| cu_State | state | ||
| ) |
Create a new hashmap.
| allocator | allocator used for storage |
| key_layout | layout describing the key type |
| value_layout | layout describing the value type |
| initial_capacity | optional initial bucket count |
| hash_fn | hashing function, defaults to FNV-1a when none |
| equals_fn | equality predicate, defaults to bytewise compare |
| state | randomization source used to seed hashes and mitigate collision attacks |


| void cu_HashMap_destroy | ( | cu_HashMap * | map | ) |
Release resources held by map.

