5 Author: Pekka Riikonen <priikone@silcnet.org>
7 Copyright (C) 2008 Pekka Riikonen
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; version 2 of the License.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
24 #error "Do not include this header directly"
27 /* Tree operatins header */
28 struct SilcTreeOpsStruct {
29 SilcBool (*add)(SilcTree *tree, void *entry);
30 SilcBool (*del)(SilcTree *tree, void *entry);
31 void *(*find)(SilcTree *tree, void *entry, SilcTreeCompare compare,
35 /* Generic tree header, present in each entry in tree */
36 struct SilcTreeHeaderStruct {
37 struct SilcTreeHeaderStruct *parent;
38 struct SilcTreeHeaderStruct *left;
39 struct SilcTreeHeaderStruct *right;
40 struct SilcTreeHeaderStruct *dup;
42 unsigned int duplicate : 1;
46 struct SilcTreeStruct {
47 const struct SilcTreeOpsStruct *ops;
49 SilcTreeCompare compare;
52 unsigned int offset : 31;
53 unsigned int duplicates : 1;
56 /* Get tree header from entry */
57 #define SILC_TREE_GET_HEADER(tree, pos) \
58 ((void *)((unsigned char *)(pos) + tree->offset))
60 /* Get entry from tree header */
61 #define SILC_TREE_GET_ENTRY(tree, pos) \
62 ((void *)((unsigned char *)(pos) - tree->offset))
64 #endif /* SILCTREE_I_H */