125 #ifndef __TOMMYTRIE_H
126 #define __TOMMYTRIE_H
141 #define TOMMY_TRIE_TREE_MAX (64 / sizeof(void*))
147 #define TOMMY_TRIE_BLOCK_SIZE (TOMMY_TRIE_TREE_MAX * sizeof(void*))
152 #define TOMMY_TRIE_TREE_BIT TOMMY_ILOG2(TOMMY_TRIE_TREE_MAX)
157 #define TOMMY_TRIE_BUCKET_BIT ((TOMMY_KEY_BIT % TOMMY_TRIE_TREE_BIT) + TOMMY_TRIE_TREE_BIT)
163 #define TOMMY_TRIE_BUCKET_MAX (1 << TOMMY_TRIE_BUCKET_BIT)
tommy_allocator * alloc
Allocator for internal nodes.
Definition: tommytrie.h:179
Allocator of fixed size blocks.
Definition: tommyalloc.h:51
tommy_uint32_t tommy_key_t
Key type used in indexed data structures to store the key or the hash value.
Definition: tommytypes.h:160
tommy_uint32_t tommy_count_t
Generic unsigned integer for counting objects.
Definition: tommytypes.h:67
tommy_trie_node * tommy_trie_bucket(tommy_trie *trie, tommy_key_t key)
Gets the bucket of the specified key.
tommy_node tommy_trie_node
Trie node.
Definition: tommytrie.h:169
void * tommy_trie_remove(tommy_trie *trie, tommy_key_t key)
Searches and removes the first element with the specified key.
Trie container type.
Definition: tommytrie.h:175
tommy_count_t tommy_trie_count(tommy_trie *trie)
Gets the number of elements.
Definition: tommytrie.h:248
tommy_count_t node_count
Number of nodes.
Definition: tommytrie.h:178
Allocator of fixed size blocks.
tommy_trie_node * bucket[TOMMY_TRIE_BUCKET_MAX]
First tree level.
Definition: tommytrie.h:176
tommy_count_t count
Number of elements.
Definition: tommytrie.h:177
void tommy_trie_insert(tommy_trie *trie, tommy_trie_node *node, void *data, tommy_key_t key)
Inserts an element in the trie.
tommy_size_t tommy_trie_memory_usage(tommy_trie *trie)
Gets the size of allocated memory.
Data structure node.
Definition: tommytypes.h:183
void * data
Pointer to the object containing the node.
Definition: tommytypes.h:200
void * tommy_trie_remove_existing(tommy_trie *trie, tommy_trie_node *node)
Removes an element from the trie.
void * tommy_trie_search(tommy_trie *trie, tommy_key_t key)
Searches an element in the trie.
Definition: tommytrie.h:228
size_t tommy_size_t
Generic size_t type.
Definition: tommytypes.h:50
void tommy_trie_init(tommy_trie *trie, tommy_allocator *alloc)
Initializes the trie.
struct tommy_trie_struct tommy_trie
Trie container type.