comparison th_datastruct.c @ 757:2ab2fece83ea

Add th_llist_length_slow().
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 01 Feb 2023 14:09:25 +0200
parents 4bd82aca5e98
children 72fb5ce9086a
comparison
equal deleted inserted replaced
756:4bd82aca5e98 757:2ab2fece83ea
201 { 201 {
202 return (list == NULL) ? 0 : list->num; 202 return (list == NULL) ? 0 : list->num;
203 } 203 }
204 204
205 205
206 size_t th_llist_length_slow(const th_llist_t *list)
207 {
208 th_llist_t *curr = list;
209 size_t i;
210
211 for (i = 0; curr != NULL; curr = curr->next, i++);
212
213 return i;
214 }
215
216
206 ssize_t th_llist_position(const th_llist_t *list, const th_llist_t *node) 217 ssize_t th_llist_position(const th_llist_t *list, const th_llist_t *node)
207 { 218 {
208 const th_llist_t *curr = list; 219 const th_llist_t *curr = list;
209 ssize_t i = 0; 220 ssize_t i = 0;
210 221