-
Notifications
You must be signed in to change notification settings - Fork 0
/
SeqList.h
138 lines (118 loc) · 3.53 KB
/
SeqList.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
//
// Created by Maylon on 2022/8/3.
//
#include "../main.h"
#ifndef DATA_STRUCTURES_ARRAY_H
#define DATA_STRUCTURES_ARRAY_H
#define DeltaSize 5
typedef struct {
ElemType *data;
int length, MaxSize;
} SeqList;
/* Create */
/*!
* Initialize or reset the sequential list
* @param L : pointer to the sequential list
* @return status (true, false)
*/
Status InitSeqList(SeqList *L);
/*!
* Increase capacity of the sequential list when the list is full
* @param L : pointer to the sequential list
* @return status (true, false)
*/
Status SeqList_Increase_Capacity(SeqList *L);
/* Destroy */
/*!
* Destroy the sequential list
* @param L : pointer to the sequential list
*/
void DestroySeqList(SeqList *L);
/* Insert */
/*!
* Insert a data from head of the sequential list
* @param L : pointer to the sequential list
* @param e : element to be inserted
* @return status (true, false)
*/
Status SeqList_Head_Insert(SeqList *L, ElemType e);
/*!
* Insert a data from tail of the sequential list
* @param L : pointer to the sequential list
* @param e : element to be insert
* @return status (true, false)
*/
Status SeqList_Tail_Insert(SeqList *L, ElemType e);
/*!
* Insert a data before a specific position of the sequential list by order
* @param L : pointer to the sequential list
* @param i : the order of a specific position, legitimate range: [1, n + 1]
* @param e : element to be insert
* @return status (true, false, input_error)
*/
Status SeqList_Insert_By_Order(SeqList *L, int i, ElemType e);
/* Delete */
/*!
* Delete a data of the sequential list by value
* @param L : pointer to the sequential list
* @param e : the data to be deleted
* @return status (true, false)
*/
Status SeqList_Delete_By_Value(SeqList *L, ElemType e);
/*!
* Delete a data of the sequential list by order
* @param L : pointer to the sequential list
* @param i : the order of a specific data, legitimate range: [1, n]
* @param e : the data to be deleted
* @return status (true, false, input_error)
*/
Status SeqList_Delete_By_Order(SeqList *L, int i, ElemType *e);
/* Retrieve */
/*!
* Retrieve a data of the sequential list by value
* @param L : pointer to the sequential list
* @param e : the data to be retrieved
* @return position (subscript) of the result if successfully retrieved else -1
*/
int SeqList_Retrieve_By_Value(SeqList *L, ElemType e);
/* Update */
/*!
* Update a data of the sequential list by value
* @param L : pointer to the sequential list
* @param old : the old data to be updated
* @param new : the new data to be updated
* @return status (true, false)
*/
Status SeqList_Update_By_Value(SeqList *L, ElemType old, ElemType new);
/*!
* Update a data of the sequential list by order
* @param L : pointer to the sequential list
* @param i : the order of a specific data, legitimate range: [1, n]
* @param e : the data to be updated
* @return status (true, false, input_error)
*/
Status SeqList_Update_By_Order(SeqList *L, int i, ElemType e);
/* Reverse */
/*!
* Reverse the sequential list
* @param L : pointer to the sequential list
* @return status (true, false)
*/
Status SeqList_Reverse(SeqList *L);
/* Traverse */
/*!
* Traverse the sequential list
* @param L : the sequential list
* @param visit : function pointer to the function that prints the data
* @return status (true, false)
*/
Status SeqList_Traverse(SeqList L, void(*visit)(ElemType e));
/*!
* The sequential list
*/
void seqlist_menu(void);
/*!
* The sequential list menu details
*/
void seqlist_menu_show_details(void);
#endif //DATA_STRUCTURES_ARRAY_H