Lines Matching refs:list
25 * \file list.h
26 * \brief Doubly-linked list abstract container type.
28 * Each doubly-linked list has a sentinel head and tail node. These nodes
33 * A list is empty if either the head sentinel's \c next pointer points to the
36 * list structure.
38 * Do note that this means that the list nodes will contain pointers into the
39 * list structure itself and as a result you may not \c realloc() an \c
76 * This creates a sort of degenerate list that is occasionally useful.
81 * Insert a node in the list after the current node
86 * Insert another list in the list after the current node
91 * Insert a node in the list before the current node
96 * Insert another list in the list before the current node
106 * Is this the sentinel at the tail of the list?
111 * Is this the sentinel at the head of the list?
323 * Remove the first node from a list and return it
326 * The first node in the list or \c NULL if the list is empty.
333 * Move all of the nodes from this list to the target list
338 * Append all nodes from the source list to the end of the target list
343 * Prepend all nodes from the source list to the beginning of the target
344 * list
351 exec_list_make_empty(struct exec_list *list)
353 list->head_sentinel.next = &list->tail_sentinel;
354 list->head_sentinel.prev = NULL;
355 list->tail_sentinel.next = NULL;
356 list->tail_sentinel.prev = &list->head_sentinel;
360 exec_list_is_empty(const struct exec_list *list)
362 /* There are three ways to test whether a list is empty or not.
372 return list->head_sentinel.next == &list->tail_sentinel;
376 exec_list_is_singular(const struct exec_list *list)
378 return !exec_list_is_empty(list) &&
379 list->head_sentinel.next->next == &list->tail_sentinel;
383 exec_list_get_head_const(const struct exec_list *list)
385 return !exec_list_is_empty(list) ? list->head_sentinel.next : NULL;
389 exec_list_get_head(struct exec_list *list)
391 return !exec_list_is_empty(list) ? list->head_sentinel.next : NULL;
395 exec_list_get_head_raw_const(const struct exec_list *list)
397 return list->head_sentinel.next;
401 exec_list_get_head_raw(struct exec_list *list)
403 return list->head_sentinel.next;
407 exec_list_get_tail_const(const struct exec_list *list)
409 return !exec_list_is_empty(list) ? list->tail_sentinel.prev : NULL;
413 exec_list_get_tail(struct exec_list *list)
415 return !exec_list_is_empty(list) ? list->tail_sentinel.prev : NULL;
419 exec_list_get_tail_raw_const(const struct exec_list *list)
421 return list->tail_sentinel.prev;
425 exec_list_get_tail_raw(struct exec_list *list)
427 return list->tail_sentinel.prev;
431 exec_list_length(const struct exec_list *list)
436 for (node = list->head_sentinel.next; node->next != NULL; node = node->next) {
444 exec_list_push_head(struct exec_list *list, struct exec_node *n)
446 n->next = list->head_sentinel.next;
447 n->prev = &list->head_sentinel;
450 list->head_sentinel.next = n;
454 exec_list_push_tail(struct exec_list *list, struct exec_node *n)
456 n->next = &list->tail_sentinel;
457 n->prev = list->tail_sentinel.prev;
460 list->tail_sentinel.prev = n;
464 exec_list_push_degenerate_list_at_head(struct exec_list *list, struct exec_node *n)
468 n->prev->next = list->head_sentinel.next;
469 list->head_sentinel.next->prev = n->prev;
470 n->prev = &list->head_sentinel;
471 list->head_sentinel.next = n;
475 exec_list_pop_head(struct exec_list *list)
477 struct exec_node *const n = exec_list_get_head(list);
485 exec_list_move_nodes_to(struct exec_list *list, struct exec_list *target)
487 if (exec_list_is_empty(list)) {
490 target->head_sentinel.next = list->head_sentinel.next;
493 target->tail_sentinel.prev = list->tail_sentinel.prev;
498 exec_list_make_empty(list);
503 exec_list_append(struct exec_list *list, struct exec_list *source)
508 /* Link the first node of the source with the last node of the target list.
510 list->tail_sentinel.prev->next = source->head_sentinel.next;
511 source->head_sentinel.next->prev = list->tail_sentinel.prev;
513 /* Make the tail of the source list be the tail of the target list.
515 list->tail_sentinel.prev = source->tail_sentinel.prev;
516 list->tail_sentinel.prev->next = &list->tail_sentinel;
518 /* Make the source list empty for good measure.
539 exec_list_prepend(struct exec_list *list, struct exec_list *source)
541 exec_list_append(source, list);
542 exec_list_move_nodes_to(source, list);
561 exec_list_validate(const struct exec_list *list)
565 assert(list->head_sentinel.next->prev == &list->head_sentinel);
566 assert(list->head_sentinel.prev == NULL);
567 assert(list->tail_sentinel.next == NULL);
568 assert(list->tail_sentinel.prev->next == &list->tail_sentinel);
574 for (node = list->head_sentinel.next; node->next != NULL; node = node->next) {
721 * Iterate through two lists at once. Stops at the end of the shorter list.