Skip to content

Commit 7afd233

Browse files
committed
Beginning node.cpp
1 parent 8455696 commit 7afd233

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

Motor/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ file ( GLOB_RECURSE SRC *.?pp )
44
SET(CMAKE_CXX_FLAGS "-std=c++11")
55

66

7-
#add_library(IAMaker SHARED ${SRC})
7+
add_library(IAMaker SHARED ${SRC})

Motor/node.cpp

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
#include "node.hpp"
22

3-
Node::Node()
3+
template <typename StateType>
4+
Node<StateType>::Node(StateType s)
45
{
56

67
}
78

8-
Node::~Node()
9+
template <typename StateType>
10+
Node<StateType>::~Node()
911
{
12+
//we delete every child
13+
for(auto it = children.begin(); it != children.end(); it++)
14+
{
15+
delete *it;
16+
}
1017

18+
//note that we did not delete the parent node, so if you want to destroy the whole tree you want to call delete on root.
1119
}
12-

Motor/node.hpp

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
#ifndef NODE_HPP
22
#define NODE_HPP
33

4+
#include <vector>
45

6+
using std::vector;
7+
8+
template <typename StateType>
59
class Node
610
{
11+
private:
12+
const Node* parent;
13+
const int depth;
14+
StateType state;
15+
double f,g,h; //f = g+h
16+
vector<Node *> children;
17+
718
public:
8-
Node();
19+
Node(StateType s);
920
~Node();
1021
};
1122

0 commit comments

Comments
 (0)