-
Notifications
You must be signed in to change notification settings - Fork 0
/
my402list.h
74 lines (58 loc) · 2.91 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
61
62
63
64
65
66
67
68
69
70
71
72
73
/******************************************************************************/
/* Important CSCI 402 usage information: */
/* */
/* This fils is part of CSCI 402 warmup programming assignments at USC. */
/* Please understand that you are NOT permitted to distribute or publically */
/* display a copy of this file (or ANY PART of it) for any reason. */
/* If anyone (including your prospective employer) asks you to post the code, */
/* you must inform them that you do NOT have permissions to do so. */
/* You are also NOT permitted to remove or alter this comment block. */
/* If this comment block is removed or altered in a submitted file, 20 points */
/* will be deducted. */
/******************************************************************************/
/*
* Author: William Chia-Wei Cheng (bill.cheng@acm.org)
*
* @(#)$Id: my402list.h,v 1.1 2014/12/20 16:42:38 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_*/