-
Notifications
You must be signed in to change notification settings - Fork 0
/
list.h
53 lines (46 loc) · 1.18 KB
/
list.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
49
50
51
52
53
#ifndef _LIST_
#define _LIST_
/* define maximum number for nodes and lists*/
#define Item void*
#define LISTMAXIMUM 1280
#define NODEMAXIMUM 1280
/*extra credit: minimum allocation for pools*/
#define MIN_LISTS 5
#define MIN_NODES 5
/* define NODE*/
typedef struct node
{
void *data;
struct node *next;
struct node *prev;
struct node *nextFreeNode;
int occupied;
} NODE;
/* define LIST*/
typedef struct list
{
int size;
struct node *first;
struct node *last;
struct node *current;
struct list *nextFreeList;
int used;
} LIST;
/*function prototype*/
LIST *ListCreate();
int ListCount(LIST *list);
void *ListFirst(LIST *list);
void *ListLast(LIST *list);
void *ListNext(LIST *list);
void *ListPrev(LIST *list);
void *ListCurr(LIST *list);
int ListAdd(LIST *list, Item item);
int ListInsert(LIST *list, Item item);
int ListAppend(LIST *list, Item item);
int ListPrepend(LIST *list, Item item);
void *ListRemove(LIST *list);
void ListConcat(LIST *list1,LIST *list2);
void ListFree(LIST *list, void (*itemFree)(Item));
void *ListTrim(LIST *list);
void *ListSearch(LIST *list, int (*comparator)(Item, Item), Item comparisonArg);
#endif