C Standard Library Extensions 1.1
|
00001 /* $Id: cxmap.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_MAP_H 00029 #define CX_MAP_H 00030 00031 #include <cxmemory.h> 00032 #include <cxtree.h> 00033 00034 CX_BEGIN_DECLS 00035 00046 typedef cx_tree cx_map; 00047 00057 typedef cx_tree_iterator cx_map_iterator; 00058 00069 typedef cx_tree_const_iterator cx_map_const_iterator; 00070 00085 typedef cx_tree_compare_func cx_map_compare_func; 00086 00087 /* 00088 * Create, copy and destroy operations 00089 */ 00090 00091 00092 cx_map *cx_map_new(cx_compare_func, cx_free_func, cx_free_func); 00093 void cx_map_delete(cx_map *); 00094 00095 /* 00096 * Nonmodifying operations 00097 */ 00098 00099 cxsize cx_map_size(const cx_map *); 00100 cxbool cx_map_empty(const cx_map *); 00101 cxsize cx_map_max_size(const cx_map *); 00102 cx_map_compare_func cx_map_key_comp(const cx_map *); 00103 00104 /* 00105 * Special search operations 00106 */ 00107 00108 cxsize cx_map_count(const cx_map *, cxcptr); 00109 cx_map_iterator cx_map_find(const cx_map *, cxcptr); 00110 cx_map_iterator cx_map_lower_bound(const cx_map *, cxcptr); 00111 cx_map_iterator cx_map_upper_bound(const cx_map *, cxcptr); 00112 void cx_map_equal_range(const cx_map *, cxcptr, cx_map_iterator *, 00113 cx_map_iterator *); 00114 00115 /* 00116 * Assignment operations 00117 */ 00118 00119 void cx_map_swap(cx_map *, cx_map *); 00120 cxptr cx_map_assign(cx_map *, cx_map_iterator, cxcptr); 00121 cxptr cx_map_put(cx_map *, cxcptr, cxcptr); 00122 00123 /* 00124 * Element access 00125 */ 00126 00127 cxptr cx_map_get_key(const cx_map *, cx_map_const_iterator); 00128 cxptr cx_map_get_value(const cx_map *, cx_map_const_iterator); 00129 cxptr cx_map_get(cx_map *, cxcptr); 00130 00131 /* 00132 * Iterator functions 00133 */ 00134 00135 cx_map_iterator cx_map_begin(const cx_map *); 00136 cx_map_iterator cx_map_end(const cx_map *); 00137 cx_map_iterator cx_map_next(const cx_map *, cx_map_const_iterator); 00138 cx_map_iterator cx_map_previous(const cx_map *, cx_map_const_iterator); 00139 00140 00141 /* 00142 * Inserting and removing elements 00143 */ 00144 00145 cx_map_iterator cx_map_insert(cx_map *, cxcptr, cxcptr); 00146 void cx_map_erase_position(cx_map *, cx_map_iterator); 00147 void cx_map_erase_range(cx_map *, cx_map_iterator, cx_map_iterator); 00148 cxsize cx_map_erase(cx_map *, cxcptr); 00149 void cx_map_clear(cx_map *); 00150 00151 CX_END_DECLS 00152 00153 #endif /* CX_MAP_H */