File tree 3 files changed +23
-5
lines changed
3 files changed +23
-5
lines changed Original file line number Diff line number Diff line change @@ -4,4 +4,4 @@ file ( GLOB_RECURSE SRC *.?pp )
4
4
SET (CMAKE_CXX_FLAGS "-std=c++11" )
5
5
6
6
7
- # add_library(IAMaker SHARED ${SRC})
7
+ add_library (IAMaker SHARED ${SRC} )
Original file line number Diff line number Diff line change 1
1
#include " node.hpp"
2
2
3
- Node::Node ()
3
+ template <typename StateType>
4
+ Node<StateType>::Node(StateType s)
4
5
{
5
6
6
7
}
7
8
8
- Node::~Node ()
9
+ template <typename StateType>
10
+ Node<StateType>::~Node ()
9
11
{
12
+ // we delete every child
13
+ for (auto it = children.begin (); it != children.end (); it++)
14
+ {
15
+ delete *it;
16
+ }
10
17
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.
11
19
}
12
-
Original file line number Diff line number Diff line change 1
1
#ifndef NODE_HPP
2
2
#define NODE_HPP
3
3
4
+ #include < vector>
4
5
6
+ using std::vector;
7
+
8
+ template <typename StateType>
5
9
class Node
6
10
{
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
+
7
18
public:
8
- Node ();
19
+ Node (StateType s );
9
20
~Node ();
10
21
};
11
22
You can’t perform that action at this time.
0 commit comments