memgraph/poc/kdtree/kdnode.hpp
Mislav Bradac 0588de76bb Move unused datastructures to poc
Reviewers: buda

Reviewed By: buda

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D526
2017-07-10 12:03:11 +02:00

47 lines
933 B
C++

#pragma once
#include <memory>
#include "point.hpp"
namespace kd {
template <class T, class U>
class KdNode {
public:
KdNode(const U& data)
: axis(0),
coord(Point<T>(0, 0)),
left(nullptr),
right(nullptr),
data(data) {}
KdNode(const Point<T>& coord, const U& data)
: axis(0), coord(coord), left(nullptr), right(nullptr), data(data) {}
KdNode(unsigned char axis, const Point<T>& coord, const U& data)
: axis(axis), coord(coord), left(nullptr), right(nullptr), data(data) {}
KdNode(unsigned char axis, const Point<T>& coord, KdNode<T, U>* left,
KdNode<T, U>* right, const U& data)
: axis(axis), coord(coord), left(left), right(right), data(data) {}
~KdNode();
unsigned char axis;
Point<T> coord;
KdNode<T, U>* left;
KdNode<T, U>* right;
U data;
};
template <class T, class U>
KdNode<T, U>::~KdNode() {
delete left;
delete right;
}
}