-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
39 lines (29 loc) · 946 Bytes
/
Copy pathmain.cpp
File metadata and controls
39 lines (29 loc) · 946 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
#include <iostream>
#include <memory>
#include <utility>
#include "stdtree.hpp"
struct Geo2D
{
double x;
double y;
Geo2D(double x, double y) : x(x), y(y) {}
friend std::ostream& operator<<(std::ostream& os, const Geo2D& geo)
{
os << "(" << geo.x << ", " << geo.y << ")";
return os;
}
};
int main()
{
TreeView<Geo2D, std::size_t> tree(std::make_unique<TreeNode<Geo2D, std::size_t>>(Geo2D(0, 0), 0, 0));
tree.getRoot()->addChild(Geo2D(1, 1));
tree.getRoot()->addChild(Geo2D(2, 2));
tree.getRoot()->getChild(0)->addChild(Geo2D(3, 3));
tree.getRoot()->getChild(0)->addChild(Geo2D(4, 4));
tree.getRoot()->getChild(1)->addChild(Geo2D(5, 5));
tree.getRoot()->getChild(1)->addChild(Geo2D(6, 6));
tree.getRoot()->getChild(1)->getChild(0)->addChild(Geo2D(7, 7));
tree.getRoot()->getChild(1)->getChild(0)->addChild(Geo2D(8, 8));
tree.printTree();
return 0;
}