This repository has been archived by the owner on Dec 21, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAVLtree.h
44 lines (38 loc) · 1.43 KB
/
AVLtree.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
32
33
34
35
36
37
38
39
40
41
42
43
44
#ifndef AVLTREE_H
#define AVLTREE_H
#include <fstream>
#include <iterator>
#include "AVLnode.h"
template <class T>
class AVLtree {
public:
AVLtree(std::string mmi, std::string mmc, std::string mmt);
~AVLtree(void);
AVLnode<T> *root;
std::string m_name_index;
std::string m_name_col;
std::string m_name_table;
bool insert(T key, std::string st);
void deleteKey(const T key);
void printBalance();
void inOrder() ;
void writeFile (std::ofstream& file);
std::vector< std::string > find (T tem);
AVLnode<T>* build_from_vec(std::vector<std::string> values, AVLnode<T>*& cur);
AVLnode<T>* build_from_vec2(std::vector<std::string> values, int start, int end);
void printPreorder(AVLnode<T>* cur);
private:
AVLnode<T>* rotateLeft ( AVLnode<T> *a );
AVLnode<T>* rotateRight ( AVLnode<T> *a );
AVLnode<T>* rotateLeftThenRight ( AVLnode<T> *n );
AVLnode<T>* rotateRightThenLeft ( AVLnode<T> *n );
void rebalance ( AVLnode<T> *n );
int height ( AVLnode<T> *n );
void setBalance ( AVLnode<T> *n );
void printBalance ( AVLnode<T> *n );
void clearNode ( AVLnode<T> *n );
void inOrder ( AVLnode<T> *n );
void writeFile (std::ofstream& file, AVLnode<T> *n);
std::vector< std::string > find (T tem, AVLnode<T> *n);
};
#endif