LinkedList.h
Go to the documentation of this file.
1 /*******************************************************************************
2  * Copyright (c) 2009, 2020 IBM Corp.
3  *
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v2.0
6  * and Eclipse Distribution License v1.0 which accompany this distribution.
7  *
8  * The Eclipse Public License is available at
9  * https://www.eclipse.org/legal/epl-2.0/
10  * and the Eclipse Distribution License is available at
11  * http://www.eclipse.org/org/documents/edl-v10.php.
12  *
13  * Contributors:
14  * Ian Craggs - initial API and implementation and/or initial documentation
15  * Ian Craggs - updates for the async client
16  * Ian Craggs - change size types from int to size_t
17  *******************************************************************************/
18 
19 #if !defined(LINKEDLIST_H)
20 #define LINKEDLIST_H
21 
22 #include <stdlib.h> /* for size_t definition */
23 
24 /*BE
25 defm defList(T)
26 
27 def T concat Item
28 {
29  at 4
30  n32 ptr T concat Item suppress "next"
31  at 0
32  n32 ptr T concat Item suppress "prev"
33  at 8
34  n32 ptr T id2str(T)
35 }
36 
37 def T concat List
38 {
39  n32 ptr T concat Item suppress "first"
40  n32 ptr T concat Item suppress "last"
41  n32 ptr T concat Item suppress "current"
42  n32 dec "count"
43  n32 suppress "size"
44 }
45 endm
46 
47 defList(INT)
48 defList(STRING)
49 defList(TMP)
50 
51 BE*/
52 
56 typedef struct ListElementStruct
57 {
59  *next;
60  void* content;
61 } ListElement;
62 
63 
67 typedef struct
68 {
69  ListElement *first,
70  *last,
71  *current;
72  int count;
73  size_t size;
74 } List;
75 
76 void ListZero(List*);
77 List* ListInitialize(void);
78 
79 ListElement* ListAppend(List* aList, void* content, size_t size);
80 void ListAppendNoMalloc(List* aList, void* content, ListElement* newel, size_t size);
81 ListElement* ListInsert(List* aList, void* content, size_t size, ListElement* index);
82 
83 int ListRemove(List* aList, void* content);
84 int ListRemoveItem(List* aList, void* content, int(*callback)(void*, void*));
85 void* ListDetachHead(List* aList);
86 int ListRemoveHead(List* aList);
87 void* ListPopTail(List* aList);
88 
89 int ListDetach(List* aList, void* content);
90 int ListDetachItem(List* aList, void* content, int(*callback)(void*, void*));
91 
92 void ListFree(List* aList);
93 void ListEmpty(List* aList);
94 void ListFreeNoContent(List* aList);
95 
98 
99 ListElement* ListFind(List* aList, void* content);
100 ListElement* ListFindItem(List* aList, void* content, int(*callback)(void*, void*));
101 
102 int intcompare(void* a, void* b);
103 int stringcompare(void* a, void* b);
104 
105 #endif
size_t size
Definition: LinkedList.h:73
ListElement * ListAppend(List *aList, void *content, size_t size)
Definition: LinkedList.c:90
void ListFreeNoContent(List *aList)
Definition: LinkedList.c:392
int ListRemoveHead(List *aList)
Definition: LinkedList.c:294
struct ListElementStruct * next
Definition: LinkedList.h:58
ListElement * ListInsert(List *aList, void *content, size_t size, ListElement *index)
Definition: LinkedList.c:107
int count
Definition: LinkedList.h:72
struct ListElementStruct ListElement
void * ListDetachHead(List *aList)
Definition: LinkedList.c:268
void ListAppendNoMalloc(List *aList, void *content, ListElement *newel, size_t size)
Definition: LinkedList.c:69
ListElement * ListNextElement(List *aList, ListElement **pos)
Definition: LinkedList.c:411
List * ListInitialize(void)
Definition: LinkedList.c:52
ListElement * ListFind(List *aList, void *content)
Definition: LinkedList.c:140
struct ListElementStruct * prev
Definition: LinkedList.h:58
int ListDetachItem(List *aList, void *content, int(*callback)(void *, void *))
Definition: LinkedList.c:335
void * ListPopTail(List *aList)
Definition: LinkedList.c:306
ListElement * last
Definition: LinkedList.h:69
int stringcompare(void *a, void *b)
Definition: LinkedList.c:448
ListElement * ListPrevElement(List *aList, ListElement **pos)
Definition: LinkedList.c:424
int intcompare(void *a, void *b)
Definition: LinkedList.c:436
void ListEmpty(List *aList)
Definition: LinkedList.c:359
int ListDetach(List *aList, void *content)
Definition: LinkedList.c:245
int ListRemoveItem(List *aList, void *content, int(*callback)(void *, void *))
Definition: LinkedList.c:349
void ListZero(List *)
Definition: LinkedList.c:42
void ListFree(List *aList)
Definition: LinkedList.c:381
ListElement * ListFindItem(List *aList, void *content, int(*callback)(void *, void *))
Definition: LinkedList.c:154
int ListRemove(List *aList, void *content)
Definition: LinkedList.c:257


plotjuggler
Author(s): Davide Faconti
autogenerated on Sun Dec 6 2020 03:48:09