C Standard Library Extensions 1.1
|
00001 /* $Id: cxtree.h,v 1.5 2011/02/21 14:15:31 rpalsa Exp $ 00002 * 00003 * This file is part of the ESO C Extension Library 00004 * Copyright (C) 2001-2011 European Southern Observatory 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00019 */ 00020 00021 /* 00022 * $Author: rpalsa $ 00023 * $Date: 2011/02/21 14:15:31 $ 00024 * $Revision: 1.5 $ 00025 * $Name: cpl-6_0 $ 00026 */ 00027 00028 #ifndef CX_TREE_H 00029 #define CX_TREE_H 00030 00031 #include <cxmemory.h> 00032 00033 CX_BEGIN_DECLS 00034 00035 typedef struct _cx_tnode_ *cx_tree_iterator; 00036 typedef const struct _cx_tnode_ *cx_tree_const_iterator; 00037 00038 typedef struct _cx_tree_ cx_tree; 00039 00075 typedef cxbool (*cx_tree_compare_func)(cxcptr, cxcptr); 00076 00077 /* 00078 * Create, copy and destroy operations 00079 */ 00080 00081 cx_tree *cx_tree_new(cx_tree_compare_func, cx_free_func, cx_free_func); 00082 void cx_tree_delete(cx_tree *); 00083 00084 /* 00085 * Nonmodifying operations 00086 */ 00087 00088 cxsize cx_tree_size(const cx_tree *); 00089 cxbool cx_tree_empty(const cx_tree *); 00090 cxsize cx_tree_max_size(const cx_tree *); 00091 cx_tree_compare_func cx_tree_key_comp(const cx_tree *); 00092 00093 /* 00094 * Special search operations 00095 */ 00096 00097 cxsize cx_tree_count(const cx_tree *, cxcptr); 00098 cx_tree_iterator cx_tree_find(const cx_tree *, cxcptr); 00099 cx_tree_iterator cx_tree_lower_bound(const cx_tree *, cxcptr); 00100 cx_tree_iterator cx_tree_upper_bound(const cx_tree *, cxcptr); 00101 void cx_tree_equal_range(const cx_tree *, cxcptr, cx_tree_iterator *, 00102 cx_tree_iterator *); 00103 00104 /* 00105 * Assignment operations 00106 */ 00107 00108 void cx_tree_swap(cx_tree *, cx_tree *); 00109 cxptr cx_tree_assign(cx_tree *, cx_tree_iterator, cxcptr); 00110 00111 /* 00112 * Element access 00113 */ 00114 00115 cxptr cx_tree_get_key(const cx_tree *, cx_tree_const_iterator); 00116 cxptr cx_tree_get_value(const cx_tree *, cx_tree_const_iterator); 00117 00118 /* 00119 * Iterator functions 00120 */ 00121 00122 cx_tree_iterator cx_tree_begin(const cx_tree *); 00123 cx_tree_iterator cx_tree_end(const cx_tree *); 00124 cx_tree_iterator cx_tree_next(const cx_tree *, cx_tree_const_iterator); 00125 cx_tree_iterator cx_tree_previous(const cx_tree *, cx_tree_const_iterator); 00126 00127 00128 /* 00129 * Inserting and removing elements 00130 */ 00131 00132 cx_tree_iterator cx_tree_insert_unique(cx_tree *, cxcptr, cxcptr); 00133 cx_tree_iterator cx_tree_insert_equal(cx_tree *, cxcptr, cxcptr); 00134 void cx_tree_erase_position(cx_tree *, cx_tree_iterator); 00135 void cx_tree_erase_range(cx_tree *, cx_tree_iterator, cx_tree_iterator); 00136 cxsize cx_tree_erase(cx_tree *, cxcptr); 00137 void cx_tree_clear(cx_tree *); 00138 00139 /* 00140 * Debugging 00141 */ 00142 00143 cxbool cx_tree_verify(const cx_tree *); 00144 00145 CX_END_DECLS 00146 00147 #endif /* CX_TREE_H */