-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlinearList.h
More file actions
68 lines (58 loc) · 1.6 KB
/
linearList.h
File metadata and controls
68 lines (58 loc) · 1.6 KB
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
#include <iostream>
class sequenceList
{
private:
float* myList=NULL;
int curNumberOfItem;
int maxCapcity;
public:
sequenceList(const int&, const int&, float[]);
~sequenceList();
bool addItem(const float&);
bool insertItem(const int&,const float&);
int deleteItem(const float&);
bool locate(const int&, float&);
int locate(const float&);
void reverse();
void print();
};
class linkList;
class listNode{
friend class linkList;
friend void merge(linkList&, linkList&);
private:
float data;
listNode* next;
public:
listNode(){next = NULL;}
listNode(float nodeData, listNode* succ = NULL);
~listNode();
};
class linkList
{
private:
listNode* firstNode;
listNode* curNode;
listNode* lastNode;
int listSize;
public:
linkList();
linkList(const int&, float[]);
~linkList();
bool headInsertItem(const float&); //按值头插
bool tailInsertItem(const float&); //按值尾插
int insertItem(const int&,const float&); //插入特定位置
int deleteItem(const float&); //按值删除
bool locate(const int&, float&); //按位查找
int locate(const float&); //按值查找
void ascendingOrder(); //升序
void reverse(); //倒排
void print(); //打印元素
linkList operator+(const linkList &b)
{
lastNode->next=b.firstNode->next;
listSize+=b.listSize;
return *this;
}
};
void merge(linkList&, linkList&);