libiec61850  1.2.0
linked_list.h
Go to the documentation of this file.
1 /*
2  * linked_list.h
3  *
4  * Copyright 2013 Michael Zillgith
5  *
6  * This file is part of libIEC61850.
7  *
8  * libIEC61850 is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * libIEC61850 is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with libIEC61850. If not, see <http://www.gnu.org/licenses/>.
20  *
21  * See COPYING file for the complete license text.
22  */
23 
24 #ifndef LINKED_LIST_H_
25 #define LINKED_LIST_H_
26 
27 #include "libiec61850_common_api.h"
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
44 struct sLinkedList {
45  void* data;
46  struct sLinkedList* next;
47 };
48 
52 typedef struct sLinkedList* LinkedList;
53 
59 LinkedList
60 LinkedList_create(void);
61 
71 void
72 LinkedList_destroy(LinkedList self);
73 
74 
75 typedef void (*LinkedListValueDeleteFunction) (void*);
76 
88 void
89 LinkedList_destroyDeep(LinkedList self, LinkedListValueDeleteFunction valueDeleteFunction);
90 
99 void
100 LinkedList_destroyStatic(LinkedList self);
101 
111 void
112 LinkedList_add(LinkedList self, void* data);
113 
122 bool
123 LinkedList_contains(LinkedList self, void* data);
124 
133 bool
134 LinkedList_remove(LinkedList self, void* data);
135 
142 LinkedList
143 LinkedList_get(LinkedList self, int index);
144 
150 LinkedList
151 LinkedList_getNext(LinkedList self);
152 
158 LinkedList
159 LinkedList_getLastElement(LinkedList self);
160 
166 LinkedList
167 LinkedList_insertAfter(LinkedList listElement, void* data);
168 
176 int
177 LinkedList_size(LinkedList self);
178 
179 void*
180 LinkedList_getData(LinkedList self);
181 
182 void
183 LinkedList_printStringList(LinkedList self);
184 
189 #ifdef __cplusplus
190 }
191 #endif
192 
193 #endif /* LINKED_LIST_H_ */
bool LinkedList_contains(LinkedList self, void *data)
Check if the specified data is contained in the list.
LinkedList LinkedList_get(LinkedList self, int index)
Get the list element specified by index (starting with 0).
void * data
Definition: linked_list.h:45
Reference to a linked list or to a linked list element.
Definition: linked_list.h:44
LinkedList LinkedList_create(void)
Create a new LinkedList object.
LinkedList LinkedList_insertAfter(LinkedList listElement, void *data)
Insert a new element int the list.
struct sLinkedList * next
Definition: linked_list.h:46
void LinkedList_destroy(LinkedList self)
Delete a LinkedList object.
void * LinkedList_getData(LinkedList self)
bool LinkedList_remove(LinkedList self, void *data)
Removed the specified element from the list.
LinkedList LinkedList_getLastElement(LinkedList self)
Get the last element in the list.
void LinkedList_destroyStatic(LinkedList self)
Delete a LinkedList object without freeing the element data.
void LinkedList_printStringList(LinkedList self)
void LinkedList_destroyDeep(LinkedList self, LinkedListValueDeleteFunction valueDeleteFunction)
Delete a LinkedList object.
void LinkedList_add(LinkedList self, void *data)
Add a new element to the list.
LinkedList LinkedList_getNext(LinkedList self)
Get the next element in the list (iterator).
int LinkedList_size(LinkedList self)
Get the size of the list.
void(* LinkedListValueDeleteFunction)(void *)
Definition: linked_list.h:75