2 * Operating system kernel abstraction -- linked lists.
4 * Copyright (C) 2009-2010 Cambridge Silicon Radio Ltd.
6 * Refer to LICENSE.txt included with this source code for details on
17 * @defgroup list Linked Lists
19 * Generic linked list implementations suitable for all platforms.
21 * - Circular, doubly-linked list (struct os_list).
27 * This list node structure should be the first field within any
28 * structure that is to be stored in a list.
35 * The pointer to the previous node in the list, or os_list_end()
36 * if the end of the list has been reached.
38 struct os_list_node
*prev
;
40 * The pointer to the next node in the list, or os_list_end() if
41 * the end of the list has been reached.
43 struct os_list_node
*next
;
47 * A circular, doubly-linked list of nodes.
49 * Structures to be stored in a list should contains a struct
50 * os_list_node as the \e first field.
53 * struct os_list_node node;
58 * Going to/from a struct foo to a list node is then simple.
60 * struct os_list_node *node;
64 * foo = (struct foo *)node
66 * Lists must be initialized with os_list_init() before adding nodes
67 * with os_list_add_tail(). The node at the head of the list is
68 * obtained with os_list_head(). Nodes are removed from the list with
71 * A list can be interated from the head to the tail using:
73 * struct os_list_node *node;
74 * for (node = os_list_head(list); node != os_list_end(list); node = node->next) {
75 * struct foo *foo = (struct foo *)node;
80 * In the above loop, the current list node cannot be removed (with
81 * os_list_del()). If this is required use this form of loop:
83 * struct os_list_node *node, *next;
84 * for (node = os_list_head(list), next = node->next;
85 * node != os_list_end(list);
86 * node = next, next = node->next) {
87 * struct foo *foo = (struct foo *)node;
99 * The dummy node marking the end of the list.
101 struct os_list_node head
;
104 void os_list_init(struct os_list
*list
);
105 int os_list_empty(struct os_list
*list
);
106 void os_list_add_tail(struct os_list
*list
, struct os_list_node
*node
);
107 void os_list_del(struct os_list_node
*node
);
108 struct os_list_node
*os_list_head(struct os_list
*list
);
109 struct os_list_node
*os_list_end(struct os_list
*list
);
115 #endif /* #ifndef __OSKA_LIST_H */
This page took 0.032515 seconds and 5 git commands to generate.