1 /*------------------------------------------------------------------------------ 2 * 3 * Copyright (c) 2011-2021, EURid vzw. All rights reserved. 4 * The YADIFA TM software product is provided under the BSD 3-clause license: 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 10 * * Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * * Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * * Neither the name of EURid nor the names of its contributors may be 16 * used to endorse or promote products derived from this software 17 * without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 20 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 23 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 * 31 *------------------------------------------------------------------------------ 32 * 33 */ 34 35 /** @defgroup dnsdbcollection Collections used by the database 36 * @ingroup dnsdb 37 * @brief Balanced Tree structures and functions for the database 38 * 39 * Definitions of the Balanced Tree structures and functions for the database. 40 * 41 * btree is the chosen balanced tree for the database. 42 * The current choice right now is AVL Tree. 43 * It could be set to something else. ie: Red-Black Tree. 44 * 45 * @{ 46 */ 47 48 #ifndef _btree_H 49 #define _btree_H 50 51 #include <dnsdb/avl.h> 52 53 #ifdef __cplusplus 54 extern "C" 55 { 56 #endif 57 58 /* 59 * The iterator returns the nodes sorted with their hash value. 60 * 61 * This macro is true for AVL 62 */ 63 64 #define BTREE_ITERATION_SORTED 1 65 66 typedef avl_node btree_node; 67 typedef avl_tree btree; 68 typedef avl_iterator btree_iterator; 69 70 71 72 #define btree_init avl_init 73 #define btree_find avl_find 74 #define btree_findp avl_findp 75 #define btree_insert avl_insert 76 #define btree_delete avl_delete 77 #define btree_destroy avl_destroy 78 #define btree_callback_and_destroy avl_callback_and_destroy 79 80 #define btree_iterator_init avl_iterator_init 81 #define btree_iterator_init_from avl_iterator_init_from_after 82 #define btree_iterator_hasnext avl_iterator_hasnext 83 #define btree_iterator_next avl_iterator_next 84 #define btree_iterator_next_node avl_iterator_next_node 85 86 #define btree_notempty(tree) ((tree)!=NULL) 87 #define btree_isempty(tree) ((tree)==NULL) 88 89 #ifdef __cplusplus 90 } 91 #endif 92 93 #endif /* _btree_H */ 94 95 /** @} */ 96