S2OPC OPCUA Toolkit
Loading...
Searching...
No Matches
sopc_singly_linked_list.h
Go to the documentation of this file.
1/*
2 * Licensed to Systerel under one or more contributor license
3 * agreements. See the NOTICE file distributed with this work
4 * for additional information regarding copyright ownership.
5 * Systerel licenses this file to you under the Apache
6 * License, Version 2.0 (the "License"); you may not use this
7 * file except in compliance with the License. You may obtain
8 * a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
26#ifndef SOPC_SINGLY_LINKED_LIST_H_
27#define SOPC_SINGLY_LINKED_LIST_H_
28
29#include <stdbool.h>
30#include <stddef.h>
31#include <stdint.h>
32
37
39
41
50
63uintptr_t SOPC_SLinkedList_Prepend(SOPC_SLinkedList* list, uint32_t id, uintptr_t value);
64
76uintptr_t SOPC_SLinkedList_Append(SOPC_SLinkedList* list, uint32_t id, uintptr_t value);
77
97 uint32_t id,
98 uintptr_t value,
99 int8_t (*pCompFn)(uintptr_t left, uintptr_t right));
100
109
119
129
139
149uintptr_t SOPC_SLinkedList_FindFromId(SOPC_SLinkedList* list, uint32_t id);
150
159void SOPC_SLinkedList_Apply(SOPC_SLinkedList* list, void (*pFn)(uint32_t id, uintptr_t val));
160
171
183
190
197
204void SOPC_SLinkedList_EltGenericFree(uint32_t id, uintptr_t val);
205
214
224
234
245
254
263
276
277#endif /* SOPC_SINGLE_LINKED_LIST_H_ */
uint32_t SOPC_SLinkedList_GetCapacity(SOPC_SLinkedList *list)
Get the maximum number of elements that can be contained in the linked list.
void SOPC_SLinkedList_EltGenericFree(uint32_t id, uintptr_t val)
Frees the value of an element of the SOPC_SLinkedList.
uintptr_t SOPC_SLinkedList_Next(SOPC_SLinkedListIterator *it)
Return the next element pointed by iterator in the linked list (iterate from head to tail)
uintptr_t SOPC_SLinkedList_SortedInsert(SOPC_SLinkedList *list, uint32_t id, uintptr_t value, int8_t(*pCompFn)(uintptr_t left, uintptr_t right))
Insert element in sorted list in correct index regarding compare function.
uintptr_t SOPC_SLinkedList_Prepend(SOPC_SLinkedList *list, uint32_t id, uintptr_t value)
Add a new element (and allocate new list element) before head of the given linked list.
uint32_t SOPC_SLinkedList_GetLength(SOPC_SLinkedList *list)
Get the number of elements in the linked list.
uintptr_t SOPC_SLinkedList_NextWithId(SOPC_SLinkedListIterator *it, uint32_t *pId)
Return the next element pointed by iterator in the linked list (iterate from head to tail)
struct SOPC_SLinkedList SOPC_SLinkedList
Singly linked list structure.
Definition sopc_singly_linked_list.h:36
SOPC_SLinkedList_Elt * SOPC_SLinkedListIterator
Definition sopc_singly_linked_list.h:40
uintptr_t SOPC_SLinkedList_PopLast(SOPC_SLinkedList *list)
Get and remove the last element of the list.
bool SOPC_SLinkedList_SetCapacity(SOPC_SLinkedList *list, size_t sizeMax)
Set the maximum number of elements that can be contained in the linked list. It might be used to modi...
uintptr_t SOPC_SLinkedList_RemoveFromValuePtr(SOPC_SLinkedList *list, uintptr_t value)
Find and remove the first value pointer equal in the linked list (iterate from head to tail)
SOPC_SLinkedList * SOPC_SLinkedList_Create(size_t sizeMax)
Create and allocate a new singly linked list containing 0 elements with a size limit of the given siz...
void SOPC_SLinkedList_Apply(SOPC_SLinkedList *list, void(*pFn)(uint32_t id, uintptr_t val))
Apply a function to the value of each element of the list.
uintptr_t SOPC_SLinkedList_GetLast(SOPC_SLinkedList *list)
Get the tail element of the list without removing it. Note: it shall not be freed.
uintptr_t SOPC_SLinkedList_RemoveFromId(SOPC_SLinkedList *list, uint32_t id)
Find and remove the first value associated to the given id in the linked list (iterate from head to t...
SOPC_SLinkedListIterator SOPC_SLinkedList_GetIterator(SOPC_SLinkedList *list)
Get an iterator on a linked list to iterate on elements from head to tail.
uintptr_t SOPC_SLinkedList_FindFromId(SOPC_SLinkedList *list, uint32_t id)
Find the first value associated to the given id in the linked list (iterate from head to tail)
bool SOPC_SLinkedList_HasNext(const SOPC_SLinkedListIterator *it)
Return true if iterator has a non NULL value to provide on next iteration (iterate from head to tail)
struct SOPC_SLinkedList_Elt SOPC_SLinkedList_Elt
Definition sopc_singly_linked_list.h:38
void SOPC_SLinkedList_Clear(SOPC_SLinkedList *list)
Delete all elements of the given linked list.
void SOPC_SLinkedList_Delete(SOPC_SLinkedList *list)
Delete and deallocate the given linked list.
uintptr_t SOPC_SLinkedList_Append(SOPC_SLinkedList *list, uint32_t id, uintptr_t value)
Add a new element (and allocate new list element) to the tail of the given linked list.
uintptr_t SOPC_SLinkedList_GetHead(SOPC_SLinkedList *list)
Get the head element of the list without removing it. Note: it shall not be freed.
uintptr_t SOPC_SLinkedList_PopHead(SOPC_SLinkedList *list)
Get and remove the head element of the list.