-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTree.h
More file actions
60 lines (47 loc) · 1.16 KB
/
Tree.h
File metadata and controls
60 lines (47 loc) · 1.16 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
//========================================================================
// Tree.h
//========================================================================
// Declarations for generic tree.
#ifndef TREE_H
#define TREE_H
#include <cstddef>
#include "Image.h"
template < typename T >
class Tree
{
public:
Tree( unsigned int K = 0 );
~Tree();
// Copy constructor
Tree( const Tree<T>& tree );
// Methods
size_t size() const;
void add( const T& value );
bool find( const T& value );
const T& find_closest( const T& value );
void print();
// Operator overloading
Tree<T>& operator=( const Tree<T>& tree );
// Node
struct Node
{
T value;
Node* left = nullptr;
Node* right = nullptr;
};
private:
size_t m_size = 0;
Node* m_root;
unsigned int m_k;
unsigned int m_diff;
T m_closest;
void dstruct( Node* arrow );
void copy( Node* treeArrow, Node* arrow );
Node* pointer( T value, Node* arrow );
bool find_h( T value, Node* arrow );
void find_closest_h( T value, Node* arrow );
void print_h( Node* arrow );
};
// Include inline definitions
#include "Tree.inl"
#endif /* TREE_H */