A sorted array based implementation of as_map
.
To use the map, you can either initialize a stack allocated map, using as_orderedmap_init()
:
Or you can create a new heap allocated map using as_orderedmap_new()
:
When you are finished using the map, then you should release the map and associated resources, using as_orderedmap_destroy()
:
The as_orderedmap
is a subtype of as_map
. This allows you to alternatively use as_map
functions, by typecasting as_orderedmap
to as_map
.
The as_stringmap
functions are simplified functions for using string key.
Each of the as_map
functions proxy to the as_orderedmap
functions. So, calling as_map_destroy()
is equivalent to calling as_orderedmap_destroy()
.
Notes:
This orderedmap implementation is NOT threadsafe.
Internally, the orderedmap 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 orderedmap is still in use.
Further, the orderedmap does not increment ref-counts of the keys or values. However when an element is removed from the orderedmap, the orderedmap will call as_val_destroy() on both the key and value. And when the orderedmap 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 orderedmap without extra ref-counts, the caller is effectively handing off ownership of these objects to the orderedmap.
Definition at line 106 of file as_orderedmap.h.
|
(Note that these are not member functions.)
|
AS_EXTERN int | as_orderedmap_clear (as_orderedmap *map) |
|
AS_EXTERN void | as_orderedmap_destroy (as_orderedmap *map) |
|
AS_EXTERN bool | as_orderedmap_foreach (const as_orderedmap *map, as_map_foreach_callback callback, void *udata) |
|
AS_EXTERN as_val * | as_orderedmap_get (const as_orderedmap *map, const as_val *key) |
|
AS_EXTERN as_orderedmap * | as_orderedmap_init (as_orderedmap *map, uint32_t capacity) |
|
AS_EXTERN as_orderedmap * | as_orderedmap_new (uint32_t capacity) |
|
AS_EXTERN int | as_orderedmap_remove (as_orderedmap *map, const as_val *key) |
|
AS_EXTERN int | as_orderedmap_set (as_orderedmap *map, const as_val *key, const as_val *val) |
|
static void | as_orderedmap_set_flags (as_orderedmap *map, uint32_t flags) |
|
AS_EXTERN uint32_t | as_orderedmap_size (const as_orderedmap *map) |
|
static int | as_map_clear (as_map *map) |
|
AS_EXTERN 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_EXTERN 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_EXTERN 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 void | as_map_set_flags (as_map *map, uint32_t flags) |
|
static uint32_t | as_map_size (const as_map *map) |
|
static as_val * | as_map_toval (const as_map *map) |
|