src/cx/linked_list.h

changeset 438
cd3069757010
parent 415
067aa769796a
child 453
bb144d08cd44
     1.1 --- a/src/cx/linked_list.h	Mon Sep 27 17:49:23 2021 +0200
     1.2 +++ b/src/cx/linked_list.h	Mon Sep 27 18:33:30 2021 +0200
     1.3 @@ -36,6 +36,25 @@
     1.4  extern "C" {
     1.5  #endif
     1.6  
     1.7 +/**
     1.8 + * Finds the node at a certain index.
     1.9 + *
    1.10 + * This function can be used to start at an arbitrary position within the list.
    1.11 + * If the search index is large than the start index, \p loc_advance must denote
    1.12 + * the location of some sort of \c next pointer (i.e. a pointer to the next node).
    1.13 + * But it is also possible that the search index is smaller than the start index
    1.14 + * (e.g. in cases where traversing a list backwards is faster) in which case
    1.15 + * \p loc_advance must denote the location of some sort of \c prev pointer
    1.16 + * (i.e. a pointer to the previous node).
    1.17 + *
    1.18 + * @param start a pointer to the start node
    1.19 + * @param start_index the start index
    1.20 + * @param loc_advance the location of the pointer to advance
    1.21 + * @param index the search index
    1.22 + * @return the node found at the specified index
    1.23 + */
    1.24 +void *cx_linked_list_at(void *start, size_t start_index, ptrdiff_t loc_advance, size_t index);
    1.25 +
    1.26  void *cx_linked_list_last(void **begin, void **end, ptrdiff_t loc_next);
    1.27  
    1.28  int cx_linked_list_add(void **begin, void **end, ptrdiff_t loc_prev, ptrdiff_t loc_next, void *new_node);

mercurial