1 #ifndef LICE_UTIL_LIST_HDR
2 #define LICE_UTIL_LIST_HDR
7 * Initialize an empty list in place
9 #define SENTINEL_LIST ((list_t) { \
16 * Type: list_iterator_t
17 * A type capable of representing an itrator for a <list>
19 typedef struct list_iterator_s list_iterator_t;
23 * A standard double-linked list
25 typedef struct list_s list_t;
28 * Function: list_create
31 list_t *list_create(void);
35 * Push an element onto a list
37 void list_push(list_t *list, void *element);
41 * Pop an element from a list
43 void *list_pop(list_t *list);
46 * Function: list_length
47 * Used to retrieve length of a list object
49 int list_length(list_t *list);
52 * Function: list_shift
53 * Like a list_pop but shift from the head (instead of the tail)
55 void *list_shift(list_t *list);
58 * Function: list_reverse
59 * Reverse the contents of a list
61 list_t *list_reverse(list_t *list);
64 * Function: list_iterator
65 * Create an iterator for a given list object
67 list_iterator_t *list_iterator(list_t *list);
70 * Function: list_iterator_next
71 * Increment the list iterator while returning the given element
73 void *list_iterator_next(list_iterator_t *iter);
76 * Function: list_iterator_end
77 * Test if the iterator is at the end of the list
79 bool list_iterator_end(list_iterator_t *iter);
83 * Get the last element in a list
86 * list - The list in question to get the last element of.
89 * The last element in the list.
91 void *list_tail(list_t *list);
95 * Get the first element in a list
98 * list - The list in question to get the first element of.
101 * The first element in the list.
103 void *list_head(list_t *list);
106 * Function: list_empty
107 * Empty the contents of a list
110 * list - The list to empty the contents of.
112 void list_empty(list_t *list);
115 * Function: list_default
116 * Create a new list default initializing the first element with
120 * item - The first item to default initialize the list with.
123 * A new list containing one element holding `item`.
125 list_t *list_default(void *item);
129 struct list_node_s *head;
130 struct list_node_s *tail;