ucx/list.h

changeset 124
8b44653541ef
parent 123
7fb0f74517c5
child 125
fca8efb122de
equal deleted inserted replaced
123:7fb0f74517c5 124:8b44653541ef
117 */ 117 */
118 void ucx_list_free(UcxList *list); 118 void ucx_list_free(UcxList *list);
119 UcxList *ucx_list_append(UcxList *list, void *data); 119 UcxList *ucx_list_append(UcxList *list, void *data);
120 UcxList *ucx_list_prepend(UcxList *list, void *data); 120 UcxList *ucx_list_prepend(UcxList *list, void *data);
121 UcxList *ucx_list_concat(UcxList *list1, UcxList *list2); 121 UcxList *ucx_list_concat(UcxList *list1, UcxList *list2);
122 UcxList *ucx_list_last(const UcxList *list); 122 /**
123 * Returns the first element of a list.
124 *
125 * If the argument is the list pointer, it is directly returned. Otherwise
126 * this function traverses to the first element of the list and returns the
127 * list pointer.
128 *
129 * @param elem one element of the list
130 * @return the first element of the list, the specified element is a member of
131 */
132 UcxList *ucx_list_first(const UcxList *elem);
133 /**
134 * Returns the last element of a list.
135 *
136 * If the argument has no successor, it is the last element and therefore
137 * directly returned. Otherwise this function traverses to the last element of
138 * the list and returns it.
139 *
140 * @param elem one element of the list
141 * @return the last element of the list, the specified element is a member of
142 */
143 UcxList *ucx_list_last(const UcxList *elem);
123 UcxList *ucx_list_get(const UcxList *list, int index); 144 UcxList *ucx_list_get(const UcxList *list, int index);
124 ssize_t ucx_list_indexof(const UcxList *list, const UcxList *elem); 145 ssize_t ucx_list_indexof(const UcxList *list, const UcxList *elem);
125 size_t ucx_list_size(const UcxList *list); 146 size_t ucx_list_size(const UcxList *list);
126 ssize_t ucx_list_find(UcxList *list, void *elem, cmp_func fnc, void *cmpdata); 147 ssize_t ucx_list_find(UcxList *list, void *elem, cmp_func cmpfnc, void *data);
127 int ucx_list_contains(UcxList *list, void *elem, cmp_func fnc, void *cmpdata); 148 int ucx_list_contains(UcxList *list, void *elem, cmp_func cmpfnc, void *data);
128 149
129 UcxList *ucx_list_sort(UcxList *list, cmp_func cmpfnc, void *data); 150 UcxList *ucx_list_sort(UcxList *list, cmp_func cmpfnc, void *data);
130 151
131 UcxList *ucx_list_first(const UcxList *list); 152 /**
153 * Removes an element from the list.
154 *
155 * If the first element is removed, the list pointer changes. So it is
156 * <i>highly recommended</i> to <i>always</i> update the pointer by calling
157 * <code>mylist = ucx_list_remove(mylist, myelem);</code>.
158 *
159 * @param list the list from which the element shall be removed
160 * @param element the element to removed
161 * @return returns the updated list pointer or <code>NULL</code>, if the list
162 * is now empty
163 */
132 UcxList *ucx_list_remove(UcxList *list, UcxList *element); 164 UcxList *ucx_list_remove(UcxList *list, UcxList *element);
133 165
134 #ifdef __cplusplus 166 #ifdef __cplusplus
135 } 167 }
136 #endif 168 #endif

mercurial