src/cx/linked_list.h

changeset 480
e3be53a3354f
parent 478
599770bb6314
child 481
eef025d82a34
equal deleted inserted replaced
479:a29bdd703e02 480:e3be53a3354f
96 */ 96 */
97 void *cx_linked_list_at(void *start, size_t start_index, ptrdiff_t loc_advance, size_t index) 97 void *cx_linked_list_at(void *start, size_t start_index, ptrdiff_t loc_advance, size_t index)
98 __attribute__((__nonnull__)); 98 __attribute__((__nonnull__));
99 99
100 /** 100 /**
101 * Finds the index of an element within a linked list.
102 *
103 * @param start a pointer to the start node
104 * @param loc_advance the location of the pointer to advance
105 * @param loc_data the location of the \c data pointer within your node struct
106 * @param follow_ptr \c false if the pointer denoted by \p loc_data shall be passed to the \p cmp_func.
107 * If \c true, the data at \p loc_data is assumed to be a pointer, dereferenced, and then passed to \p cmp_func.
108 * @param cmp_func a compare function to compare \p elem against the node data
109 * @param elem a pointer to the element to find
110 * @return the index of the element or a past-one index if the element could not be found
111 */
112 size_t cx_linked_list_find(void *start, ptrdiff_t loc_advance, ptrdiff_t loc_data, int follow_ptr,
113 CxListComparator cmp_func, void *elem)
114 __attribute__((__nonnull__));
115
116 /**
101 * Finds the first node in a linked list. 117 * Finds the first node in a linked list.
102 * 118 *
103 * The function starts with the pointer denoted by \p node and traverses the list 119 * The function starts with the pointer denoted by \p node and traverses the list
104 * along a prev pointer whose location within the node struct is 120 * along a prev pointer whose location within the node struct is
105 * denoted by \p loc_prev. 121 * denoted by \p loc_prev.
224 * @param end a pointer to the end node pointer (optional) 240 * @param end a pointer to the end node pointer (optional)
225 * @param loc_prev the location of a \c prev pointer within your node struct (negative if not present) 241 * @param loc_prev the location of a \c prev pointer within your node struct (negative if not present)
226 * @param loc_next the location of a \c next pointer within your node struct (required) 242 * @param loc_next the location of a \c next pointer within your node struct (required)
227 * @param loc_data the location of the \c data pointer within your node struct 243 * @param loc_data the location of the \c data pointer within your node struct
228 * @param follow_ptr \c false if the pointer denoted by \p loc_data shall be passed to the \p cmp_func. 244 * @param follow_ptr \c false if the pointer denoted by \p loc_data shall be passed to the \p cmp_func.
229 * If \c true, the data at \p loc_data is dereferenced, assuming to be a pointer, and then passed to \p cmp_func. 245 * If \c true, the data at \p loc_data is assumed to be a pointer, dereferenced, and then passed to \p cmp_func.
230 * @param cmp_func the compare function defining the sort order 246 * @param cmp_func the compare function defining the sort order
231 */ 247 */
232 void cx_linked_list_sort(void **begin, void **end, ptrdiff_t loc_prev, ptrdiff_t loc_next, 248 void cx_linked_list_sort(void **begin, void **end, ptrdiff_t loc_prev, ptrdiff_t loc_next,
233 ptrdiff_t loc_data, int follow_ptr, CxListComparator cmp_func) 249 ptrdiff_t loc_data, int follow_ptr, CxListComparator cmp_func)
234 __attribute__((__nonnull__(1, 7))); 250 __attribute__((__nonnull__(1, 7)));

mercurial