C Standard Library Extensions  1.1
cxmap.h
1 /* $Id: cxmap.h,v 1.5 2011/02/21 14:15:31 rpalsa Exp $
2  *
3  * This file is part of the ESO C Extension Library
4  * Copyright (C) 2001-2011 European Southern Observatory
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 /*
22  * $Author: rpalsa $
23  * $Date: 2011/02/21 14:15:31 $
24  * $Revision: 1.5 $
25  * $Name: cpl-6_1_1 $
26  */
27 
28 #ifndef CX_MAP_H
29 #define CX_MAP_H
30 
31 #include <cxmemory.h>
32 #include <cxtree.h>
33 
34 CX_BEGIN_DECLS
35 
46 typedef cx_tree cx_map;
47 
57 typedef cx_tree_iterator cx_map_iterator;
58 
69 typedef cx_tree_const_iterator cx_map_const_iterator;
70 
86 
87 /*
88  * Create, copy and destroy operations
89  */
90 
91 
92 cx_map *cx_map_new(cx_compare_func, cx_free_func, cx_free_func);
93 void cx_map_delete(cx_map *);
94 
95 /*
96  * Nonmodifying operations
97  */
98 
99 cxsize cx_map_size(const cx_map *);
100 cxbool cx_map_empty(const cx_map *);
101 cxsize cx_map_max_size(const cx_map *);
103 
104 /*
105  * Special search operations
106  */
107 
108 cxsize cx_map_count(const cx_map *, cxcptr);
109 cx_map_iterator cx_map_find(const cx_map *, cxcptr);
110 cx_map_iterator cx_map_lower_bound(const cx_map *, cxcptr);
111 cx_map_iterator cx_map_upper_bound(const cx_map *, cxcptr);
112 void cx_map_equal_range(const cx_map *, cxcptr, cx_map_iterator *,
113  cx_map_iterator *);
114 
115 /*
116  * Assignment operations
117  */
118 
119 void cx_map_swap(cx_map *, cx_map *);
120 cxptr cx_map_assign(cx_map *, cx_map_iterator, cxcptr);
121 cxptr cx_map_put(cx_map *, cxcptr, cxcptr);
122 
123 /*
124  * Element access
125  */
126 
129 cxptr cx_map_get(cx_map *, cxcptr);
130 
131 /*
132  * Iterator functions
133  */
134 
139 
140 
141 /*
142  * Inserting and removing elements
143  */
144 
145 cx_map_iterator cx_map_insert(cx_map *, cxcptr, cxcptr);
148 cxsize cx_map_erase(cx_map *, cxcptr);
149 void cx_map_clear(cx_map *);
150 
151 CX_END_DECLS
152 
153 #endif /* CX_MAP_H */