src/cx/linked_list.h

changeset 1162
e3bb67b72d33
parent 1113
dce04550fbef
equal deleted inserted replaced
1161:747c4baed44f 1162:e3bb67b72d33
109 ptrdiff_t loc_advance, 109 ptrdiff_t loc_advance,
110 size_t index 110 size_t index
111 ); 111 );
112 112
113 /** 113 /**
114 * Finds the index of an element within a linked list. 114 * Finds the node containing an element within a linked list.
115 * 115 *
116 * @param start a pointer to the start node 116 * @param start a pointer to the start node
117 * @param loc_advance the location of the pointer to advance 117 * @param loc_advance the location of the pointer to advance
118 * @param loc_data the location of the @c data pointer within your node struct 118 * @param loc_data the location of the @c data pointer within your node struct
119 * @param cmp_func a compare function to compare @p elem against the node data 119 * @param cmp_func a compare function to compare @p elem against the node data
120 * @param elem a pointer to the element to find 120 * @param elem a pointer to the element to find
121 * @return the index of the element or a negative value if it could not be found 121 * @param found_index an optional pointer where the index of the found node
122 */ 122 * (given that @p start has index 0) is stored
123 cx_attr_nonnull 123 * @return the index of the element, if found - unspecified if not found
124 ssize_t cx_linked_list_find( 124 */
125 cx_attr_nonnull_arg(1, 4, 5)
126 void *cx_linked_list_find(
125 const void *start, 127 const void *start,
126 ptrdiff_t loc_advance, 128 ptrdiff_t loc_advance,
127 ptrdiff_t loc_data, 129 ptrdiff_t loc_data,
128 cx_compare_func cmp_func, 130 cx_compare_func cmp_func,
129 const void *elem 131 const void *elem,
130 ); 132 size_t *found_index
131
132 /**
133 * Finds the node containing an element within a linked list.
134 *
135 * @param result a pointer to the memory where the node pointer (or @c NULL if the element
136 * could not be found) shall be stored to
137 * @param start a pointer to the start node
138 * @param loc_advance the location of the pointer to advance
139 * @param loc_data the location of the @c data pointer within your node struct
140 * @param cmp_func a compare function to compare @p elem against the node data
141 * @param elem a pointer to the element to find
142 * @return the index of the element or a negative value if it could not be found
143 */
144 cx_attr_nonnull
145 ssize_t cx_linked_list_find_node(
146 void **result,
147 const void *start,
148 ptrdiff_t loc_advance,
149 ptrdiff_t loc_data,
150 cx_compare_func cmp_func,
151 const void *elem
152 ); 133 );
153 134
154 /** 135 /**
155 * Finds the first node in a linked list. 136 * Finds the first node in a linked list.
156 * 137 *

mercurial