-
Notifications
You must be signed in to change notification settings - Fork 0
/
my402list.h
60 lines (46 loc) · 1.95 KB
/
my402list.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
54
55
56
57
58
59
60
/*
* Author: William Chia-Wei Cheng ([email protected])
*
* @(#)$Id: my402list.h,v 1.1 2014/01/05 00:22:16 william Exp $
*/
#ifndef _MY402LIST_H_
#define _MY402LIST_H_
#include "cs402.h"
typedef struct tagMy402ListElem {
void *obj;
struct tagMy402ListElem *next;
struct tagMy402ListElem *prev;
} My402ListElem;
typedef struct tagMy402List {
int num_members;
My402ListElem anchor;
/* You do not have to set these function pointers */
int (*Length)(struct tagMy402List *);
int (*Empty)(struct tagMy402List *);
int (*Append)(struct tagMy402List *, void*);
int (*Prepend)(struct tagMy402List *, void*);
void (*Unlink)(struct tagMy402List *, My402ListElem*);
void (*UnlinkAll)(struct tagMy402List *);
int (*InsertBefore)(struct tagMy402List *, void*, My402ListElem*);
int (*InsertAfter)(struct tagMy402List *, void*, My402ListElem*);
My402ListElem *(*First)(struct tagMy402List *);
My402ListElem *(*Last)(struct tagMy402List *);
My402ListElem *(*Next)(struct tagMy402List *, My402ListElem *cur);
My402ListElem *(*Prev)(struct tagMy402List *, My402ListElem *cur);
My402ListElem *(*Find)(struct tagMy402List *, void *obj);
} My402List;
extern int My402ListLength(My402List*);
extern int My402ListEmpty(My402List*);
extern int My402ListAppend(My402List*, void*);
extern int My402ListPrepend(My402List*, void*);
extern void My402ListUnlink(My402List*, My402ListElem*);
extern void My402ListUnlinkAll(My402List*);
extern int My402ListInsertAfter(My402List*, void*, My402ListElem*);
extern int My402ListInsertBefore(My402List*, void*, My402ListElem*);
extern My402ListElem *My402ListFirst(My402List*);
extern My402ListElem *My402ListLast(My402List*);
extern My402ListElem *My402ListNext(My402List*, My402ListElem*);
extern My402ListElem *My402ListPrev(My402List*, My402ListElem*);
extern My402ListElem *My402ListFind(My402List*, void*);
extern int My402ListInit(My402List*);
#endif /*_MY402LIST_H_*/