-
Notifications
You must be signed in to change notification settings - Fork 0
/
CirDoLinkList.h
144 lines (124 loc) · 4.83 KB
/
CirDoLinkList.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
//
// Created by Maylon on 2022/7/21.
//
#include "LinkList.h"
#ifndef DATA_STRUCTURES_CIRDOLINKLIST_H
#define DATA_STRUCTURES_CIRDOLINKLIST_H
typedef struct CirDoLNode {
ElemType data;
struct CirDoLNode *prior;
struct CirDoLNode *next;
} CirDoLNode, *CirDoList;
/* Create */
/*!
* Initialize or reset the circular double linked list (without a head node)
* @param L : pointer to the circular double linked list pointer
*/
void InitCirDoList(CirDoList *L);
/* Destroy */
/*!
* Destroy the circular double linked list (without a head node)
* @param L : pointer to the circular double linked list pointer
* @return status (true, false)
*/
Status DestroyCirDoList(CirDoList *L);
/* Insert */
/*!
* Insert a node from head of the circular double linked list (without a head node)
* @param L : pointer to the circular double linked list pointer
* @param e : element to be inserted
* @return status (true, false)
*/
Status CirDoList_Head_Insert(CirDoList *L, ElemType e);
/*!
* Insert a node from tail of the circular double linked list (without a head node)
* @param L : pointer to the circular double linked list pointer
* @param e : element to be insert
* @return status (true, false)
*/
Status CirDoList_Tail_Insert(CirDoList *L, ElemType e);
/*!
* Insert a node before a specific node of the circular double linked list (without a head node) by order
* @param L : pointer to the circular double linked list pointer
* @param i : the order of a specific node, legitimate range: [1, n + 1]
* @param e : element to be insert
* @return status (true, false, input_error)
*/
Status CirDoList_Insert_By_Order(CirDoList *L, int i, ElemType e);
/* Delete */
/*!
* Delete a node of the circular double linked list (without a head node) by the specific node
* @param L : pointer to the circular double linked list pointer
* @param p : pointer to the node to be deleted
*/
void CirDoList_Delete_By_Node(CirDoList *L, CirDoLNode *p);
/*!
* Delete a node of the circular double linked list (without a head node) by value
* @param L : pointer to the circular double linked list pointer
* @param e : the data of the node to be deleted
* @return status (true, false)
*/
Status CirDoList_Delete_By_Value(CirDoList *L, ElemType e);
/*!
* Delete a node of the circular double linked list (without a head node) by order
* @param L : pointer to the circular double linked list pointer
* @param i : the order of a specific node, legitimate range: [1, n]
* @param e : the data of the node to be deleted
* @return status (true, false, input_error)
*/
Status CirDoList_Delete_By_Order(CirDoList *L, int i, ElemType *e);
/* Retrieve */
/*!
* Retrieve a node of the circular double linked list (without a head node) by value
* @param L : pointer to the circular double linked list
* @param e : the data of the node to be retrieved
* @return pointer to the result node if successfully retrieved else NULL
*/
CirDoLNode *CirDoList_Retrieve_By_Value(CirDoList L, ElemType e);
/*!
* Retrieve a node of the circular double linked list (without a head node) by order (only used in update and delete function)
* @param L : pointer to the circular double linked list
* @param i : the order of a specific node, legitimate range: [1, n]
* @return pointer to the result node if successfully retrieved else NULL
*/
CirDoLNode *CirDoList_Retrieve_By_Order(CirDoList L, int i);
/* Update */
/*!
* Update a node of the circular double linked list (without a head node) by value
* @param L : pointer to the circular double linked list
* @param old : the old data of the node to be updated
* @param new : the new data of the node to be updated
* @return status (true, false)
*/
Status CirDoList_Update_By_Value(CirDoList L, ElemType old, ElemType new);
/*!
* Update a node of the circular double linked list (without a head node) by order
* @param L : pointer to the circular double linked list
* @param i : the order of a specific node, legitimate range: [1, n]
* @param e : the data of the node to be updated
* @return status (true, false, input_error)
*/
Status CirDoList_Update_By_Order(CirDoList L, int i, ElemType e);
/* Reverse */
/*!
* Reverse the circular double linked list (without a head node)
* @param L : pointer to the circular double linked list pointer
* @return status (true, false)
*/
Status CirDoList_Reverse(CirDoList *L);
/* Traverse */
/*!
* Traverse the circular double linked list (without a head node)
* @param L : pointer to the circular double linked list
* @param visit : function pointer to the function that prints the data of a node
*/
void CirDoList_Traverse(CirDoList L, void(*visit)(ElemType e));
/*!
* The circular double linked list (without a head node) menu
*/
void cirdolinklist_menu(void);
/*!
* The circular double linked list (without a head node) menu details
*/
void cirdolinklist_menu_show_details(void);
#endif //DATA_STRUCTURES_CIRDOLINKLIST_H