-
Notifications
You must be signed in to change notification settings - Fork 0
/
bintree.h
31 lines (26 loc) · 935 Bytes
/
bintree.h
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
#ifndef BINTREE_H
#define BINTREE_H
#include "binnode.h"
template <class Type>
class BinTree{
BinNode<Type>* root = nullptr;
void free(BinNode<Type>* cursor);
void writeFile(std::ofstream& ofs, BinNode<Type>* obj) const;
void printElement(BinNode<Type>* cursor);
void inOrder(BinNode<Type>* cursor, int , int& , void process(Type , int , int& ));
void copyTree(BinNode<Type>* cursor);
public:
BinTree() {} // Empty tree
~BinTree() { free(root); }
bool isEmpty() const { return root == nullptr; }
void add(Type dataIn);
bool writeFile(std::string fileName) const;
void clearAll() { free(root); }
bool readFile(std::string fileName);
void printAll() const { printElement(root); }
void inOrderTraversal(int , void process(Type , int , int& ));
BinTree(const BinTree<Type>& source);
BinTree<Type>& operator=(const BinTree<Type>& source);
};
#include "bintree.template"
#endif