ucx/map.h

changeset 124
80609f9675f1
parent 0
1f419bd32da1
child 152
62921b370c60
equal deleted inserted replaced
123:55adc92e7c09 124:80609f9675f1
1 /* 1 /*
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. 2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3 * 3 *
4 * Copyright 2013 Olaf Wintermann. All rights reserved. 4 * Copyright 2015 Olaf Wintermann. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met: 7 * modification, are permitted provided that the following conditions are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
144 UcxMap *ucx_map_new_a(UcxAllocator *allocator, size_t size); 144 UcxMap *ucx_map_new_a(UcxAllocator *allocator, size_t size);
145 145
146 /** 146 /**
147 * Frees a hash map. 147 * Frees a hash map.
148 * 148 *
149 * <b>Note:</b> the contents are <b>not</b> freed, use an UcxMempool for that 149 * <b>Note:</b> the contents are <b>not</b> freed, use ucx_map_free_content()
150 * purpose. 150 * before calling this function to achieve that.
151 * 151 *
152 * @param map the map to be freed 152 * @param map the map to be freed
153 * @see ucx_map_free_content()
153 */ 154 */
154 void ucx_map_free(UcxMap *map); 155 void ucx_map_free(UcxMap *map);
156
157 /**
158 * Frees the contents of a hash map.
159 *
160 * This is a convenience function that iterates over the map and passes all
161 * values to the specified destructor function (e.g. stdlib free()).
162 *
163 * You must ensure, that it is valid to pass each value in the map to the same
164 * destructor function.
165 *
166 * You should free or clear the map afterwards, as the contents will be invalid.
167 *
168 * @param map for which the contents shall be freed
169 * @param destr pointer to the destructor function
170 * @see ucx_map_free()
171 * @see ucx_map_clear()
172 */
173 void ucx_map_free_content(UcxMap *map, ucx_destructor destr);
174
175 /**
176 * Clears a hash map.
177 *
178 * <b>Note:</b> the contents are <b>not</b> freed, use ucx_map_free_content()
179 * before calling this function to achieve that.
180 *
181 * @param map the map to be cleared
182 * @see ucx_map_free_content()
183 */
184 void ucx_map_clear(UcxMap *map);
185
155 186
156 /** 187 /**
157 * Copies contents from a map to another map using a copy function. 188 * Copies contents from a map to another map using a copy function.
158 * 189 *
159 * <b>Note:</b> The destination map does not need to be empty. However, if it 190 * <b>Note:</b> The destination map does not need to be empty. However, if it

mercurial