A hashtable based implementation of as_map
.
To use the map, you can either initialize a stack allocated map, using as_hashmap_init()
:
Or you can create a new heap allocated map using as_hashmap_new()
:
When you are finished using the map, then you should release the map and associated resources, using as_hashmap_destroy()
:
The as_hashmap
is a subtype of as_map
. This allows you to alternatively use as_map
functions, by typecasting as_hashmap
to as_map
.
The as_stringmap
functions are simplified functions for using string key.
Each of the as_map
functions proxy to the as_hashmap
functions. So, calling as_map_destroy()
is equivalent to calling as_hashmap_destroy()
.
Notes:
This hashmap implementation is NOT threadsafe.
Internally, the hashmap stores keys' and values' pointers - it does NOT copy the keys or values, so the caller must ensure these keys and values are not destroyed while the hashmap is still in use.
Further, the hashmap does not increment ref-counts of the keys or values. However when an element is removed from the hashmap, the hashmap will call as_val_destroy() on both the key and value. And when the hashmap is cleared or destroyed, as_val_destroy() will be called for all keys and values. Therefore if the caller inserts keys and values in the hashmap without extra ref-counts, the caller is effectively handing off ownership of these objects to the hashmap.
Definition at line 105 of file as_hashmap.h.
|
(Note that these are not member functions.)
|
int | as_hashmap_clear (as_hashmap *map) |
|
void | as_hashmap_destroy (as_hashmap *map) |
|
bool | as_hashmap_foreach (const as_hashmap *map, as_map_foreach_callback callback, void *udata) |
|
as_val * | as_hashmap_get (const as_hashmap *map, const as_val *key) |
|
uint32_t | as_hashmap_hashcode (const as_hashmap *map) |
|
as_hashmap * | as_hashmap_init (as_hashmap *map, uint32_t buckets) |
|
as_hashmap * | as_hashmap_new (uint32_t buckets) |
|
int | as_hashmap_remove (as_hashmap *map, const as_val *key) |
|
int | as_hashmap_set (as_hashmap *map, const as_val *key, const as_val *val) |
|
uint32_t | as_hashmap_size (const as_hashmap *map) |
|
static int | as_map_clear (as_map *map) |
|
as_map * | as_map_cons (as_map *map, bool free, uint32_t flags, const as_map_hooks *hooks) |
|
static void | as_map_destroy (as_map *map) |
|
static bool | as_map_foreach (const as_map *map, as_map_foreach_callback callback, void *udata) |
|
static as_map * | as_map_fromval (const as_val *val) |
|
static as_val * | as_map_get (const as_map *map, const as_val *key) |
|
static uint32_t | as_map_hashcode (const as_map *map) |
|
as_map * | as_map_init (as_map *map, const as_map_hooks *hooks) |
|
static union as_map_iterator_u * | as_map_iterator_init (union as_map_iterator_u *it, const as_map *map) |
|
static union as_map_iterator_u * | as_map_iterator_new (const as_map *map) |
|
as_map * | as_map_new (const as_map_hooks *hooks) |
|
static int | as_map_remove (as_map *map, const as_val *key) |
|
static int | as_map_set (as_map *map, const as_val *key, const as_val *val) |
|
static uint32_t | as_map_size (const as_map *map) |
|
static as_val * | as_map_toval (const as_map *map) |
|