summaryrefslogtreecommitdiff
path: root/apps/plugins/puzzles/src/tree234.h
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/puzzles/src/tree234.h')
-rw-r--r--apps/plugins/puzzles/src/tree234.h24
1 files changed, 23 insertions, 1 deletions
diff --git a/apps/plugins/puzzles/src/tree234.h b/apps/plugins/puzzles/src/tree234.h
index ccd943d69d..b58f939a0a 100644
--- a/apps/plugins/puzzles/src/tree234.h
+++ b/apps/plugins/puzzles/src/tree234.h
@@ -31,7 +31,11 @@
31#include <stdbool.h> 31#include <stdbool.h>
32 32
33/* 33/*
34 * This typedef is opaque outside tree234.c itself. 34 * This typedef is typically opaque outside tree234.c itself. But you
35 * can define TREE234_INTERNALS to get a definition of it and its
36 * subsidiary node structure, as long as you're prepared to commit to
37 * responding to changes in the internals (which probably means you're
38 * tree234.c itself or tree234-test.c).
35 */ 39 */
36typedef struct tree234_Tag tree234; 40typedef struct tree234_Tag tree234;
37 41
@@ -39,6 +43,24 @@ typedef int (*cmpfn234)(void *, void *);
39 43
40typedef void *(*copyfn234)(void *state, void *element); 44typedef void *(*copyfn234)(void *state, void *element);
41 45
46#ifdef TREE234_INTERNALS
47typedef struct node234_Tag node234;
48
49struct tree234_Tag {
50 node234 *root;
51 cmpfn234 cmp;
52};
53
54struct node234_Tag {
55 node234 *parent;
56 node234 *kids[4];
57 int counts[4];
58 void *elems[3];
59};
60
61int height234(tree234 *t);
62#endif
63
42/* 64/*
43 * Create a 2-3-4 tree. If `cmp' is NULL, the tree is unsorted, and 65 * Create a 2-3-4 tree. If `cmp' is NULL, the tree is unsorted, and
44 * lookups by key will fail: you can only look things up by numeric 66 * lookups by key will fail: you can only look things up by numeric