src/cx/kv_list.h

changeset 1404
ae80e36c05c7
parent 1394
7b23c6db9500
equal deleted inserted replaced
1403:09eca27b27e9 1404:ae80e36c05c7
265 static inline int cx_kv_list_set_key_str(CxList *list, size_t index, const char *key) { 265 static inline int cx_kv_list_set_key_str(CxList *list, size_t index, const char *key) {
266 return cx_kv_list_set_key(list, index, cx_hash_key_str(key)); 266 return cx_kv_list_set_key(list, index, cx_hash_key_str(key));
267 } 267 }
268 268
269 /** 269 /**
270 * Removes the key of a list item.
271 *
272 * This can be useful if you want to explicitly remove an item from the lookup map.
273 *
274 * If no key is associated with the item, nothing happens, and this function returns zero.
275 *
276 * @param list the list
277 * @param index the index of the element in the list
278 * @retval zero success
279 * @retval non-zero the index is out of bounds
280 */
281 cx_attr_nonnull
282 cx_attr_export
283 int cxKvListRemoveKey(CxList *list, size_t index);
284
285 /**
286 * Returns the key of a list item.
287 *
288 * @param list the list
289 * @param index the index of the element in the list
290 * @return a pointer to the key or @c NULL when the index is out of bounds or the item does not have a key
291 */
292 cx_attr_nonnull
293 cx_attr_export
294 const CxHashKey *cxKvListGetKey(CxList *list, size_t index);
295
296 /**
297 * Inserts an item into the list at the specified index and associates it with the specified key. 270 * Inserts an item into the list at the specified index and associates it with the specified key.
298 * 271 *
299 * @param list (@c CxList*) the list 272 * @param list (@c CxList*) the list
300 * @param index (@c size_t) the index the inserted element shall have 273 * @param index (@c size_t) the index the inserted element shall have
301 * @param key (@c CxHashKey, @c char*, @c cxstring, or @c cxmutstr) the key 274 * @param key (@c CxHashKey, @c char*, @c cxstring, or @c cxmutstr) the key
328 } 301 }
329 302
330 #endif 303 #endif
331 304
332 /** 305 /**
306 * Removes the key of a list item.
307 *
308 * This can be useful if you want to explicitly remove an item from the lookup map.
309 *
310 * If no key is associated with the item, nothing happens, and this function returns zero.
311 *
312 * @param list the list
313 * @param index the index of the element in the list
314 * @retval zero success
315 * @retval non-zero the index is out of bounds
316 */
317 cx_attr_nonnull
318 cx_attr_export
319 int cxKvListRemoveKey(CxList *list, size_t index);
320
321 /**
322 * Returns the key of a list item.
323 *
324 * @param list the list
325 * @param index the index of the element in the list
326 * @return a pointer to the key or @c NULL when the index is out of bounds or the item does not have a key
327 */
328 cx_attr_nonnull
329 cx_attr_export
330 const CxHashKey *cxKvListGetKey(CxList *list, size_t index);
331
332 /**
333 * Adds an item into the list and associates it with the specified key. 333 * Adds an item into the list and associates it with the specified key.
334 * 334 *
335 * @param list (@c CxList*) the list 335 * @param list (@c CxList*) the list
336 * @param key (@c CxHashKey, @c char*, @c cxstring, or @c cxmutstr) the key 336 * @param key (@c CxHashKey, @c char*, @c cxstring, or @c cxmutstr) the key
337 * @param value (@c void*) the value 337 * @param value (@c void*) the value

mercurial