4 * @brief Generic Double Linked List
9 * Copyright (C) 2005 Jan Hutter, Martin Willi
10 * Hochschule fuer Technik Rapperswil
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23 #ifndef LINKED_LIST_H_
24 #define LINKED_LIST_H_
30 * @brief Double Linked List Element type
32 typedef struct linked_list_element_s linked_list_element_t
;
34 struct linked_list_element_s
{
35 linked_list_element_t
*previous
;
36 linked_list_element_t
*next
;
37 /* value of a list item */
41 * @brief Destroys a linked_list_element object
43 * @param linked_list_element_t calling object
44 * @returns SUCCESS if succeeded, FAILED otherwise
46 status_t (*destroy
) (linked_list_element_t
*this);
50 * @brief Creates an empty linked list object
52 * @param value value of item
54 * @return linked_list_element object
56 linked_list_element_t
*linked_list_element_create(void *value
);
60 * @brief Double Linked List type
62 typedef struct linked_list_s linked_list_t
;
65 struct linked_list_s
{
68 linked_list_element_t
*first
;
69 linked_list_element_t
*last
;
72 * @brief inserts a new item at the beginning of the list
74 * @param linked_list calling object
75 * @param item value to insert in list
76 * @returns SUCCESS if succeeded, FAILED otherwise
78 status_t (*insert_first
) (linked_list_t
*linked_list
, void *item
);
81 * @brief removes the first item in the list and returns its value
83 * @param linked_list calling object
84 * @param item returned value of first item
85 * @returns SUCCESS if succeeded, FAILED otherwise
87 status_t (*remove_first
) (linked_list_t
*linked_list
, void **item
);
90 * @brief Returns the value of the first list item without removing it
92 * @param linked_list calling object
93 * @param item returned value of first item
94 * @returns SUCCESS if succeeded, FAILED otherwise
96 status_t (*get_first
) (linked_list_t
*linked_list
, void **item
);
99 * @brief inserts a new item at the end of the list
101 * @param linked_list calling object
102 * @param item value to insert in list
103 * @returns SUCCESS if succeeded, FAILED otherwise
105 status_t (*insert_last
) (linked_list_t
*linked_list
, void *item
);
108 * @brief removes the last item in the list and returns its value
110 * @param linked_list calling object
111 * @param item returned value of last item
112 * @returns SUCCESS if succeeded, FAILED otherwise
114 status_t (*remove_last
) (linked_list_t
*linked_list
, void **item
);
117 * @brief Returns the value of the last list item without removing it
119 * @param linked_list calling object
120 * @param item returned value of last item
121 * @returns SUCCESS if succeeded, FAILED otherwise
123 status_t (*get_last
) (linked_list_t
*linked_list
, void **item
);
126 * @brief Destroys a linked_list object
128 * @param linked_list calling object
129 * @returns SUCCESS if succeeded, FAILED otherwise
131 status_t (*destroy
) (linked_list_t
*linked_list
);
137 * Creates an empty linked list object
139 linked_list_t
*linked_list_create(void);
142 #endif /*LINKED_LIST_H_*/