ets_multimap.c
Include dependency graph for ets_multimap.c:
Defines
-
DYNARRAY_INITIAL_CAPACITY 8
-
DYNARRAY_GROWTH_FACTOR 2
-
LARGE_PRIME_INITIAL 16777259
-
LARGE_PRIME_ATOM 16777643
-
LARGE_PRIME_INTEGER 16777781
-
LARGE_PRIME_FLOAT 16777973
-
LARGE_PRIME_PID 16778147
-
LARGE_PRIME_REF 16778441
-
LARGE_PRIME_BINARY 16780483
-
LARGE_PRIME_TUPLE 16778821
-
LARGE_PRIME_LIST 16779179
-
LARGE_PRIME_MAP 16779449
-
LARGE_PRIME_PORT 16778077
Functions
-
static uint32_t hash_term(term t, GlobalContext *global)
-
static EtsMultimapEntry *entry_new(term tuple)
-
static void entry_delete(EtsMultimapEntry *entry, GlobalContext *global)
-
static EtsMultimapNode *node_new(EtsMultimapNode *next, EtsMultimapEntry *entries)
-
static void node_delete(EtsMultimapNode *node, GlobalContext *global)
-
static ets_result_t node_find(EtsMultimap *multimap, term key, EtsMultimapNode **out_node, GlobalContext *global)
-
static term node_key(EtsMultimap *multimap, EtsMultimapNode *node)
-
static void multimap_to_single(EtsMultimap *multimap, GlobalContext *global)
-
static void insert_revert(EtsMultimap *multimap, EtsMultimapEntry **entries, size_t count, GlobalContext *global)
-
static ets_result_t tuple_exists(EtsMultimapNode *node, term tuple, bool *exists, GlobalContext *global)
-
EtsMultimap *ets_multimap_new(ets_multimap_type_t type, size_t key_index)
Create a new multimap.
- Parameters:
type – the multimap type
index – the index of the tuple element to use as key
- Returns:
the created multimap, or NULL on error
-
void ets_multimap_delete(EtsMultimap *multimap, GlobalContext *global)
Delete the multimap and all its contents.
- Parameters:
multimap – the multimap
global – the global context
-
ets_result_t ets_multimap_lookup(EtsMultimap *multimap, term key, term **tuples, size_t *count, GlobalContext *global)
Lookup tuples by key.
Note
Terms returned by this function come from the ETS heap and should be copied to the process heap if needed.
Note
The returned tuples are ordered in reverse insertion order (most recently added elements first).
Warning
The caller is responsible for freeing the memory pointed to by
tuplesusingfree(). When count is zero, memory is not allocated.- Parameters:
multimap – the multimap
key – the key to lookup
tuples – [out] the found tuples (or NULL to only get the count)
count – [out] the number of found tuples; must not be NULL
global – the global context
- Returns:
EtsOk on success, otherwise an error status
-
ets_result_t ets_multimap_insert(EtsMultimap *multimap, term *tuples, size_t count, GlobalContext *global)
Insert one or more tuples into the multimap.
Note
Terms passed to this function will be copied to the ETS heap.
- Parameters:
multimap – the multimap
tuples – the tuples to insert
count – the number of tuples to insert
- Returns:
EtsOk on success, otherwise an error status
-
ets_result_t ets_multimap_remove(EtsMultimap *multimap, term key, GlobalContext *global)
Remove all tuples with the given key.
- Parameters:
multimap – the multimap
key – the key to lookup
global – the global context
- Returns:
EtsOk on success, otherwise an error status
-
ets_result_t ets_multimap_remove_tuple(EtsMultimap *multimap, term tuple, GlobalContext *global)
Remove a given tuple from the multimap.
- Parameters:
multimap – the multimap
tuple – the tuple to remove
global – the global context
- Returns:
EtsOk on success, otherwise an error status
-
static uint32_t hash_atom(term t, uint32_t h, GlobalContext *global)
-
static uint32_t hash_integer(term t, uint32_t h, GlobalContext *global)
-
static uint32_t hash_float(term t, uint32_t h, GlobalContext *global)
-
static uint32_t hash_local_pid(term t, uint32_t h, GlobalContext *global)
-
static uint32_t hash_local_port(term t, uint32_t h, GlobalContext *global)
-
static uint32_t hash_external_pid(term t, uint32_t h, GlobalContext *global)
-
static uint32_t hash_external_port(term t, uint32_t h, GlobalContext *global)
-
static uint32_t hash_local_reference(term t, uint32_t h, GlobalContext *global)
-
static uint32_t hash_external_reference(term t, uint32_t h, GlobalContext *global)
-
static uint32_t hash_binary(term t, uint32_t h, GlobalContext *global)
-
static uint32_t hash_term_incr(term t, uint32_t h, GlobalContext *global)