libiec61850  1.5.3
linked_list.h
Go to the documentation of this file.
1 /*
2  * linked_list.h
3  *
4  * Copyright 2013-2021 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 LIB61850_API LinkedList
61 
71 LIB61850_API void
72 LinkedList_destroy(LinkedList self);
73 
74 
75 typedef void (*LinkedListValueDeleteFunction) (void*);
76 
88 LIB61850_API void
89 LinkedList_destroyDeep(LinkedList self, LinkedListValueDeleteFunction valueDeleteFunction);
90 
99 LIB61850_API void
100 LinkedList_destroyStatic(LinkedList self);
101 
111 LIB61850_API void
112 LinkedList_add(LinkedList self, void* data);
113 
122 LIB61850_API bool
123 LinkedList_contains(LinkedList self, void* data);
124 
133 LIB61850_API bool
134 LinkedList_remove(LinkedList self, void* data);
135 
142 LIB61850_API LinkedList
143 LinkedList_get(LinkedList self, int index);
144 
150 LIB61850_API LinkedList
151 LinkedList_getNext(LinkedList self);
152 
158 LIB61850_API LinkedList
159 LinkedList_getLastElement(LinkedList self);
160 
166 LIB61850_API LinkedList
167 LinkedList_insertAfter(LinkedList listElement, void* data);
168 
176 LIB61850_API int
177 LinkedList_size(LinkedList self);
178 
179 LIB61850_API void*
180 LinkedList_getData(LinkedList self);
181 
182 LIB61850_API void
183 LinkedList_printStringList(LinkedList self);
184 
189 #ifdef __cplusplus
190 }
191 #endif
192 
193 #endif /* LINKED_LIST_H_ */
LIB61850_API bool LinkedList_remove(LinkedList self, void *data)
Removed the specified element from the list.
void(* LinkedListValueDeleteFunction)(void *)
Definition: linked_list.h:75
LIB61850_API LinkedList LinkedList_insertAfter(LinkedList listElement, void *data)
Insert a new element int the list.
LIB61850_API void * LinkedList_getData(LinkedList self)
LIB61850_API void LinkedList_destroy(LinkedList self)
Delete a LinkedList object.
LIB61850_API void LinkedList_printStringList(LinkedList self)
LIB61850_API LinkedList LinkedList_getNext(LinkedList self)
Get the next element in the list (iterator).
LIB61850_API LinkedList LinkedList_get(LinkedList self, int index)
Get the list element specified by index (starting with 0).
LIB61850_API LinkedList LinkedList_getLastElement(LinkedList self)
Get the last element in the list.
LIB61850_API int LinkedList_size(LinkedList self)
Get the size of the list.
LIB61850_API void LinkedList_destroyDeep(LinkedList self, LinkedListValueDeleteFunction valueDeleteFunction)
Delete a LinkedList object.
LIB61850_API LinkedList LinkedList_create(void)
Create a new LinkedList object.
LIB61850_API bool LinkedList_contains(LinkedList self, void *data)
Check if the specified data is contained in the list.
LIB61850_API void LinkedList_destroyStatic(LinkedList self)
Delete a LinkedList object without freeing the element data.
LIB61850_API void LinkedList_add(LinkedList self, void *data)
Add a new element to the list.
Reference to a linked list or to a linked list element.
Definition: linked_list.h:44
void * data
Definition: linked_list.h:45
struct sLinkedList * next
Definition: linked_list.h:46