src/cx/map.h

changeset 659
4a06fd63909a
parent 658
56c62780582e
child 668
d7129285ac32
equal deleted inserted replaced
658:56c62780582e 659:4a06fd63909a
110 ); 110 );
111 111
112 /** 112 /**
113 * Removes an element. 113 * Removes an element.
114 */ 114 */
115 __attribute__((__nonnull__, __warn_unused_result__)) 115 __attribute__((__nonnull__))
116 void *(*remove)( 116 void *(*remove)(
117 CxMap *map, 117 CxMap *map,
118 CxHashKey key 118 CxHashKey key
119 ); 119 );
120 120
257 } 257 }
258 258
259 /** 259 /**
260 * Removes a key/value-pair from the map by using the key. 260 * Removes a key/value-pair from the map by using the key.
261 * 261 *
262 * If this map is storing pointers, you should make sure that the map
263 * is not the last location where this pointer is stored.
264 * Otherwise, use cxMapRemoveAndGet() to retrieve the pointer while
265 * removing it from the map.
266 *
262 * @param map the map 267 * @param map the map
263 * @param key the key 268 * @param key the key
264 * @return if this map is storing pointers, the removed value, \c NULL otherwise 269 * @see cxMapRemoveAndGet()
270 */
271 __attribute__((__nonnull__))
272 static inline void cxMapRemove(
273 CxMap *map,
274 CxHashKey key
275 ) {
276 (void) map->cl->remove(map, key);
277 }
278
279 /**
280 * Removes a key/value-pair from the map by using the key.
281 *
282 * This function should only be used when the map is storing pointers,
283 * in order to retrieve the pointer you are about to remove.
284 * In any other case, cxMapRemove() is sufficient.
285 *
286 * @param map the map
287 * @param key the key
288 * @return the stored pointer or \c NULL if either the key is not present
289 * in the map or the map is not storing pointers
265 * @see cxMapStorePointers() 290 * @see cxMapStorePointers()
266 */ 291 */
267 __attribute__((__nonnull__, __warn_unused_result__)) 292 __attribute__((__nonnull__, __warn_unused_result__))
268 static inline void *cxMapRemove( 293 static inline void *cxMapRemoveAndGet(
269 CxMap *map, 294 CxMap *map,
270 CxHashKey key 295 CxHashKey key
271 ) { 296 ) {
272 return map->cl->remove(map, key); 297 return map->cl->remove(map, key);
273 } 298 }

mercurial