-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathLinkedList.h
48 lines (40 loc) · 1.23 KB
/
LinkedList.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#ifndef LINKEDLIST_INCLUDED
#define LINKEDLIST_INCLUDED
// General-Purpose Enumerable (Doubly) Linked List Implementation
// -- Wim Decelle
#include "Features.h"
#ifdef SYNCHRONIZED//synchronization is platform specific here :: so porting requires changes here
#include <windows.h>
#endif
typedef struct LinkedListElementStruct
{
void * value;
struct LinkedListElementStruct * next;
struct LinkedListElementStruct * prev;
} LinkedListElement;
typedef struct LinkedListStruct
{
LinkedListElement * head;
LinkedListElement * tail;
unsigned int itemcount;
#ifdef SYNCHRONIZED
LPCRITICAL_SECTION LLSync;
#endif
} LinkedList;
typedef struct LinkedListEnumStruct
{
LinkedListElement * current;
LinkedList * oflist;
} LinkedListEnum;
LinkedList * LL_create();
void LL_push(LinkedList * onlist, void * topush);
void * LL_pop(LinkedList * fromlist);
void * LL_dequeue(LinkedList * fromlist);
void LL_delete(LinkedList * todelete);
void LL_enumdelete(LinkedListEnum * todelete);
void * LL_next(LinkedListEnum * onenum);
void * LL_previous(LinkedListEnum * onenum);
void * LL_reset(LinkedListEnum * onenum);
void * LL_end(LinkedListEnum * onenum);
LinkedListEnum * LL_newenum(LinkedList * fromlist);
#endif