diff options
Diffstat (limited to 'apps/plugins/puzzles/src/tree234.h')
-rw-r--r-- | apps/plugins/puzzles/src/tree234.h | 24 |
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 | */ |
36 | typedef struct tree234_Tag tree234; | 40 | typedef struct tree234_Tag tree234; |
37 | 41 | ||
@@ -39,6 +43,24 @@ typedef int (*cmpfn234)(void *, void *); | |||
39 | 43 | ||
40 | typedef void *(*copyfn234)(void *state, void *element); | 44 | typedef void *(*copyfn234)(void *state, void *element); |
41 | 45 | ||
46 | #ifdef TREE234_INTERNALS | ||
47 | typedef struct node234_Tag node234; | ||
48 | |||
49 | struct tree234_Tag { | ||
50 | node234 *root; | ||
51 | cmpfn234 cmp; | ||
52 | }; | ||
53 | |||
54 | struct node234_Tag { | ||
55 | node234 *parent; | ||
56 | node234 *kids[4]; | ||
57 | int counts[4]; | ||
58 | void *elems[3]; | ||
59 | }; | ||
60 | |||
61 | int 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 |