docs/Writerside/topics/kv_list.h.md

changeset 1394
7b23c6db9500
parent 1390
ff077f793c5d
equal deleted inserted replaced
1393:461d256e32c6 1394:7b23c6db9500
56 56
57 int cxKvListSetKey(CxList *list, size_t index, KeyType key); 57 int cxKvListSetKey(CxList *list, size_t index, KeyType key);
58 58
59 int cxKvListRemoveKey(CxList *list, size_t index); 59 int cxKvListRemoveKey(CxList *list, size_t index);
60 60
61 const CxHashKey *cxKvListGetKey(CxList *list, size_t index);
62
61 int cxKvListAdd(CxList *list, KeyType key, void *value); 63 int cxKvListAdd(CxList *list, KeyType key, void *value);
62 64
63 int cxKvListInsert(CxList *list, size_t index, 65 int cxKvListInsert(CxList *list, size_t index,
64 KeyType key, void *value); 66 KeyType key, void *value);
65 ``` 67 ```
71 73
72 The `cxKvListSetKey()` and `cxKvListRemoveKey()` functions are used to set or remove the key of an element. 74 The `cxKvListSetKey()` and `cxKvListRemoveKey()` functions are used to set or remove the key of an element.
73 They return zero on success and non-zero on failure. 75 They return zero on success and non-zero on failure.
74 A failure can happen when the index is out of bounds or when a memory allocation failed. 76 A failure can happen when the index is out of bounds or when a memory allocation failed.
75 The `cxKvListSetKey()` function also returns non-zero if the key already exists for _another_ element. 77 The `cxKvListSetKey()` function also returns non-zero if the key already exists for _another_ element.
78 With `cxKvListGetKey()`, you can retrieve the key of an element.
79 This function returns `NULL` when an element has no key assigned or the index is out of bounds.
76 80
77 With the `cxKvListAdd()` and `cxKvListInsert()` functions, you can add a new element to the list and immediately assign a key to it. 81 With the `cxKvListAdd()` and `cxKvListInsert()` functions, you can add a new element to the list and immediately assign a key to it.
78 The `cxKvListAdd()` function will add the element at the end of the list, 82 The `cxKvListAdd()` function will add the element at the end of the list,
79 while the `cxKvListInsert()` function will insert the element at the specified index. 83 while the `cxKvListInsert()` function will insert the element at the specified index.
80 84

mercurial