-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathelement.cpp
More file actions
54 lines (44 loc) · 778 Bytes
/
element.cpp
File metadata and controls
54 lines (44 loc) · 778 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
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <stdio.h>
#include <stdlib.h>
#include "element.h"
Element::Element(){
_parent = _child = NULL;
_prev = _next = this;
}
Element::~Element(){
}
Element* Element::next(){
if (_next == this){
return NULL;
}
return _next;
}
Element* Element::prev(){
if (_prev == this){
return NULL;
}
return _prev;
}
Element* Element::child(){
return _child;
}
bool Element::setParent(Element* parent){
_parent = parent;
}
bool Element::addChild(Element* child){
_child = child;
if (NULL != child){
child->setParent(this);
}
return true;
}
bool Element::addNeighbor(Element* neighbor){
if (NULL == neighbor){
return false;
}
neighbor->_prev = this;
neighbor->_next = _next;
_next->_prev = neighbor;
_next = neighbor;
neighbor->setParent(_parent);
}