-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode.h
More file actions
83 lines (81 loc) · 2.78 KB
/
node.h
File metadata and controls
83 lines (81 loc) · 2.78 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#ifndef _node_h_
#define _node_h_
//Includes
#include <string>
#include <iostream>
/*
the following class is to abstract linking operations
of a node from calculus_tree class
*/
class node
{
private:
template<typename DataType>
friend class calculus_tree;
//a symbol can be 3.5515, v1,x,any_name
std::string symbol ;
//links
node *parent ;
node *left ;
node *right ;
/*
this function disconects self or this from it's parent
but it's children are still with him
*/
bool disconnect_self(void);
/*
where (this) must have a parent
this function adds a new child to parent of (this)
or a new sibling to (this)
*/
bool append_next(const std::string &);
/*
this function adds a child to (this)
in the order -> left then right
if it doesn't have place then it doesn't
*/
bool append_child(const std::string &);
/*
if (this) has a parent then this function
disconnects (this) from its parent
then assign a new parent to it
else it just assigns a new parent to it
*/
bool append_parent(const std::string &);
/*
previous operations but done one nodes or subtrees
*/
/*
this function disconnects src_root from it's parent
then adds it to children of parent of (this)
if applicable else it doesn't
*/
bool append_next(node*&src_root);
/*
this function disconnects src_root from it's parent
then adds it to children of (this)
if applicable else it doesn't
*/
bool append_child(node*&src_root);
/*
this function disconnects (this) from it's parent
then adds it to children of src_root if applicable
*/
bool append_parent(node*&src_root);
/*
op becomes parent of (this)
and parent (this) becomes parent of (op)
check below diagram
*/
/*
p1 p1
| ->exchange_parent(p2)-> |
this p2
|
this
*/
bool exchange_parent(const std::string &op) ;
public:
node(const std::string &);
};
#endif