summaryrefslogtreecommitdiffstats
path: root/src/trie.h
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2023-03-31 16:19:45 -0400
committerTavian Barnes <tavianator@tavianator.com>2023-03-31 16:39:56 -0400
commit86f4b4f7180bca73a734249e67dada708f8275ff (patch)
tree408bdffc5001ce8180dc46f10d4cc04ea7c17d82 /src/trie.h
parentf75f3de63888702f29f48bcf2691291403720b9d (diff)
downloadbfs-86f4b4f7180bca73a734249e67dada708f8275ff.tar.xz
list: Use macros instead of type-erased lists
Diffstat (limited to 'src/trie.h')
-rw-r--r--src/trie.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/trie.h b/src/trie.h
index 6e1e875..58974aa 100644
--- a/src/trie.h
+++ b/src/trie.h
@@ -5,7 +5,6 @@
#define BFS_TRIE_H
#include "config.h"
-#include "list.h"
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
@@ -15,7 +14,7 @@
*/
struct trie_leaf {
/** Linked list of leaves, in insertion order. */
- struct link link;
+ struct trie_leaf *prev, *next;
/** An arbitrary value associated with this leaf. */
void *value;
/** The length of the key in bytes. */
@@ -31,7 +30,7 @@ struct trie {
/** Pointer to the root node/leaf. */
uintptr_t root;
/** Linked list of leaves. */
- struct list leaves;
+ struct trie_leaf *head, *tail;
};
/**
@@ -134,6 +133,8 @@ void trie_destroy(struct trie *trie);
* Iterate over the leaves of a trie.
*/
#define TRIE_FOR_EACH(trie, leaf) \
- LIST_FOR_EACH(&(trie)->leaves, struct trie_leaf, leaf)
+ for (struct trie_leaf *leaf = (trie)->head, *_next; \
+ leaf && (_next = leaf->next, true); \
+ leaf = _next)
#endif // BFS_TRIE_H