-
Notifications
You must be signed in to change notification settings - Fork 5
/
AVLTree.hpp
42 lines (31 loc) · 836 Bytes
/
AVLTree.hpp
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
// Created by Kadir Emre Oto on 06.08.2018.
#ifndef AVLTree_hpp
#define AVLTree_hpp
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include "AVLTreeNode.hpp"
template <class T>
class AVLTree {
int _size;
AVLTreeNode<T> *root;
void balance(std::vector<AVLTreeNode<T>**> path);
void display(AVLTreeNode<T>* cur, int depth=0, int state=0);
public:
AVLTree();
~AVLTree();
void insert(T value);
void erase(T value);
void clear();
bool empty() const;
int size() const;
int find(T value) const;
int lower_bound(T value) const;
int upper_bound(T value) const;
const T& find_min() const;
const T& find_max() const;
const T& operator[](std::size_t idx) const;
void display();
};
#endif /* AVLTree_hpp */