1 /*******************************************************************************
2 3 Bindings for Elastic Binary Trees library's generic operations and
4 structures.
5 6 This module contains the D binding of the library functions of ebtree.h.
7 Please consult the original header documentation for details.
8 9 You need to have the library installed and link with -lebtree.
10 11 Copyright:
12 Copyright (c) 2009-2016 dunnhumby Germany GmbH.
13 All rights reserved.
14 15 License:
16 Boost Software License Version 1.0. See LICENSE_BOOST.txt for details.
17 Alternatively, this file may be distributed under the terms of the Tango
18 3-Clause BSD License (see LICENSE_BSD.txt for details).
19 20 Bear in mind this module provides bindings to an external library that
21 has its own license, which might be more restrictive. Please check the
22 external library license to see which conditions apply for linking.
23 24 *******************************************************************************/25 26 moduleocean.util.container.ebtree.c.ebtree;
27 28 29 importocean.meta.types.Qualifiers;
30 31 32 /// See original's library documentation for details.33 aliasvoideb_troot_t;
34 35 /// See original's library documentation for details.36 structeb_root37 {
38 enumBITS = 1;
39 enumBRANCHES = (1 << BITS);
40 41 enumRGHT = 1;
42 enumNORMAL = cast(eb_troot_t*)0;
43 enumUNIQUE = cast(eb_troot_t*)1;
44 45 eb_troot_t*[BRANCHES] b;
46 47 boolis_empty ( )
48 {
49 return !!eb_is_empty(&this);
50 }
51 52 /***************************************************************************
53 54 Tells whether this tree is configured so that the `eb*_insert` functions
55 allow adding unique nodes only or if they allow adding duplicates.
56 57 Returns:
58 true if only unique nodes are added for this tree or false if
59 duplicates can be added.
60 61 ***************************************************************************/62 63 boolunique ( )
64 {
65 returnthis.b[RGHT] isUNIQUE;
66 }
67 68 /***************************************************************************
69 70 Configures this tree so that the `eb*_insert` functions either allow
71 adding unique nodes only or allow adding duplicates.
72 73 This configuration can be changed at any time and affects subsequent
74 `eb*_insert` function calls.
75 76 Params:
77 enable = true: only allow unique nodes;
78 false: allow adding duplicates
79 80 Returns:
81 enable
82 83 ***************************************************************************/84 85 boolunique ( boolenable )
86 {
87 this.b[RGHT] = enable? UNIQUE : NORMAL;
88 returnenable;
89 }
90 }
91 92 /// See original's library documentation for details.93 structeb_node94 {
95 eb_rootbranches;
96 eb_troot_t* node_p,
97 leaf_p;
98 shortbit;
99 shortpfx;
100 101 alias .eb_firstfirst;
102 103 alias .eb_lastlast;
104 105 typeof(&this) prev( )
106 {
107 returneb_prev(&this);
108 }
109 110 typeof(&this) next ( )
111 {
112 returneb_next(&this);
113 }
114 115 typeof(&this) prev_unique ( )
116 {
117 returneb_prev_unique(&this);
118 }
119 120 typeof(&this) next_unique ( )
121 {
122 returneb_next_unique(&this);
123 }
124 125 voidremove ( )
126 {
127 eb_delete(&this);
128 }
129 };
130 131 132 extern (C):
133 134 /// See original's library documentation for details.135 inteb_is_empty(eb_root* root);
136 137 /// See original's library documentation for details.138 eb_node* eb_first(eb_root* root);
139 140 /// See original's library documentation for details.141 eb_node* eb_last(eb_root* root);
142 143 /// See original's library documentation for details.144 eb_node* eb_prev(eb_node* node);
145 146 /// See original's library documentation for details.147 eb_node* eb_next(eb_node* node);
148 149 /// See original's library documentation for details.150 eb_node* eb_prev_unique(eb_node* node);
151 152 /// See original's library documentation for details.153 eb_node* eb_next_unique(eb_node* node);
154 155 /// See original's library documentation for details.156 voideb_delete(eb_node* node);
157 158 /// See original's library documentation for details.159 intequal_bits(char* a, char* b, intignore, intlen);
160 161 /// See original's library documentation for details.162 intcheck_bits(char* a, char* b, intskip, intlen);
163 164 /// See original's library documentation for details.165 intstring_equal_bits(char* a, char* b, intignore);
166 167 /// See original's library documentation for details.168 intcmp_bits(char* a, char* b, uintpos);
169 170 /// See original's library documentation for details.171 intget_bit(char* a, uintpos);