LibRCG  3.1.1
list.h
Go to the documentation of this file.
1 
11 #ifndef _LIST_H_
12 #define _LIST_H_
13 
14 #include "iterator.h"
15 
19 typedef struct sListNode
20 {
22  void* value;
24  struct sListNode* prev;
26  struct sListNode* next;
27 }SListNode;
28 
33 
37 typedef struct sList
38 {
40  int size;
45 }SList;
46 
50 typedef SList* List;
51 
52 //==============================================================================
53 
61 List newList(void);
62 
72 void listDelete(List list);
73 
84 int listInsertFst(List list,void* value);
85 
96 int listInsertLst(List list,void* value);
97 
113 int listInsertAt(List list,int index,void* value);
114 
132 int listRemoveFst(List list,void** value);
133 
152 int listRemoveLst(List list,void** value);
153 
172 int listRemoveAt(List list,int index,void** value);
173 
191 int listFst(List list,void** value);
192 
210 int listLst(List list,void** value);
211 
230 int listAt(List list,int index,void** value);
231 
240 int listSize(List list);
241 
254 int listMap(List list,void(*fun)(void*));
255 
268 
269 #endif
ListNode last
Last node.
Definition: list.h:44
struct sListNode * next
Next node.
Definition: list.h:26
int listRemoveLst(List list, void **value)
Removes the last element of a list.
Definition: list.c:189
int listSize(List list)
Returns the size of a list.
Definition: list.c:298
int listInsertAt(List list, int index, void *value)
Inserts an new element at the specified position of a list.
Definition: list.c:116
SListNode * ListNode
Linked list node definition.
Definition: list.h:32
int listInsertFst(List list, void *value)
Inserts an element at the beginning of a list.
Definition: list.c:42
Iterator listIterator(List list)
Creates an iterator from a list.
Definition: list.c:320
int size
Number of elements of this linked list.
Definition: list.h:40
int listAt(List list, int index, void **value)
Provides the element at the specified position of a list.
Definition: list.c:278
Iterator structure.
Definition: iterator.h:17
void listDelete(List list)
Deletes a list.
Definition: list.c:27
int listRemoveAt(List list, int index, void **value)
Removes the element at the specified position of a list.
Definition: list.c:220
ListNode first
First node.
Definition: list.h:42
Linked list node structure.
Definition: list.h:19
List newList(void)
Creates a list.
Definition: list.c:13
int listRemoveFst(List list, void **value)
Removes the first element of a list.
Definition: list.c:158
struct sListNode * prev
Previous node.
Definition: list.h:24
int listInsertLst(List list, void *value)
Inserts an element at the end of a list.
Definition: list.c:79
SList * List
Linked list definition.
Definition: list.h:50
int listLst(List list, void **value)
Provides the value at the last position of a list.
Definition: list.c:264
int listMap(List list, void(*fun)(void *))
Applies a function to the elements of a list.
Definition: list.c:305
Linked list structure.
Definition: list.h:37
Implementation of an iterator.
void * value
Node's value.
Definition: list.h:22
int listFst(List list, void **value)
Provides the value at the first position of a list.
Definition: list.c:250

LibRCG © 2004-2015   Rui Carlos Gonçalves