-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathQuadlist.cpp
More file actions
41 lines (34 loc) · 830 Bytes
/
Quadlist.cpp
File metadata and controls
41 lines (34 loc) · 830 Bytes
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
//
// Created by LSC on 2020/3/18.
//
#include "Quadlist.h"
void Quadlist::init() {
header = new Quadlistnode();
trailer = new Quadlistnode();
header ->succ = trailer;
header ->pred =nullptr;
header ->above=nullptr;
header ->below=nullptr;
trailer ->pred=header;
trailer ->below=nullptr;
trailer ->above=nullptr;
trailer ->succ=nullptr;
_size=0;
}
int Quadlist::clear() {
int old_size =_size;
while (0<_size) remove(header->succ);
return old_size;
}
Entry Quadlist::remove(Quadlistnode *p) {
p->pred->succ=p->succ;
p->succ->pred=p->pred;
_size--;
Entry e=p->entry;
delete p;
return e;
}
Quadlistnode * Quadlist::insertAfterAbove(Entry const &e, Quadlistnode *p, Quadlistnode *b,bool d) {
_size++;
return p->insertAsSuccAbove(e,b,d);
}