-
Notifications
You must be signed in to change notification settings - Fork 1
/
List.h
103 lines (81 loc) · 2.25 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/**********************************************************************************
*
* Raj Maitra
* Rmaitra
* pa5
*
***********************************************************************************/
#if !defined(_LIST_H_INCLUDE_)
#define _LIST_H_INCLUDE_
/***************************** Exported Types *************************************/
typedef struct List * ListRef;
/************** Constructors-Destructors ******************************************/
/*
* newList
* Returns ListRef pointing to new ListStruct which represents an empty List.
* Initializes front and back fields to NULL, sets length field to 0. Exported.
*/
ListRef newList(void);
/*
* freeList
* Frees all heap memory associated with the ListRef *pL, including all memory
* in existing Nodes. Sets *pL to NULL. Exported.
*/
void freeList(ListRef* pL);
/***************** Access functions ***********************************************/
/*
* getFront
* Returns the value at the front of L.
* Pre: !isEmpty(L)
*/
int getFront(ListRef L);
int getBack(ListRef L);
int getCurrent(ListRef L);
/*
* getLength
* Returns the length of Q
*/
int getLength(ListRef L);
int getIndex(ListRef L);
/*
* isEmpty
* Returns True if L is empty, otherwise returns false
*/
int isEmpty(ListRef L);
int offEnd(ListRef L);
/****************************** Manipulation procedures ***************************/
void makeEmpty(ListRef L);
void moveTo(ListRef L, int data);
void movePrev(ListRef L);
void moveNext(ListRef L);
/*
* insertBack
* Places new data element at the end of Q
* Post: !isEmpty(Q)
*/
void insertFront(ListRef L, int data);
void insertBack(ListRef L, int data);
void insertBeforeCurrent(ListRef L, int data);
void insertAfterCurrent(ListRef L, int data);
/*
* deleteFront
* Deletes element at front of Q
* Pre: !isEmpty(Q)
*/
void deleteFront(ListRef L);
void deleteBack(ListRef L);
void deleteCurrent(ListRef L);
/*************** Other Functions *************************************************/
/*
* printQueue
* Prints data elements in Q on a single line to stdout.
*/
void printList(FILE *out, ListRef L);
void printflist(ListRef L);
/*
* equals
* returns true if A is identical to B, false otherwise
*/
int equals(ListRef L, ListRef P);
ListRef copyList(ListRef L);
#endif