-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMyList.h
60 lines (40 loc) · 1.08 KB
/
MyList.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
#ifndef MYLIST_H
#define MYLIST_H
class List {
struct Node {
Node* next;
int value;
};
//Âîçâðàùàåò ïîñëåäíèé ýëåìåíò â ñïèñêå (ñ ïîìîùüþ îáõîäà)
Node* back();
public:
List();
~List();
//Âîçâðàùàåò true åñëè ñïèñîê ïóñòîé
bool empty();
const Node *getHead() { return this->_head; }
//Âîçâðàùàåò óêàçàòåëü íà ïîñëåäíèé ýëåìåíò â ñïèñêå (ñ ïîìîùüþ îáõîäà)
const Node *cback();
// äîáàâèòü â êîíåö
void push_back(const int value);
// âîçâðàùàåò çíà÷åíèå ïîñëåäíåãî óäàë¸ííîãî ýëåìåíòà
int pop_back();
//If List is empty then insert in first position
void insert(const int position, const int value);
// óäàëÿåì ýëåìåíò ïî ïîçèöèè
void erase(const int position);
// óäàëÿåì âcå óçëû
void clear();
// ñîðòèðóåì íàø ñïèñîê
void sort();
// ðàçìåð ëèñòà
size_t size() { return _size; }
//Èíâåðòèðîâàíèå ñïèñêà
void invert();
//Âîçâðàùàåò çíà÷åíèå ñðåäíåãî ýëåìåíòà ñïèñêà
int middle();
private:
Node* _head = nullptr;
size_t _size = 0;
};
#endif // !MYLIST_H