-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHashTable_CA.h
73 lines (53 loc) · 1.08 KB
/
HashTable_CA.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#pragma once
#include <iostream>
using namespace std;
class BST;
class Node_BST
{
Node_BST* parent;
Node_BST* left;
Node_BST* right;
int bf;
int hl;
int hp;
int key;
int value;
public:
Node_BST(int v, int k);
Node_BST() : value(0), key(0), bf(0), hl(0), hp(0), parent(nullptr), left(nullptr), right(nullptr) {}
friend class BST;
};
class BST
{
Node_BST* root;
bool is_empty;
int size_BST;
int get_key() const;
int get_value() const;
void insert(Node_BST *& node , int v, int k);
public:
BST() : root(nullptr), is_empty(true), size_BST(0) {}
void insert_BST(int v, int k);
void remove_BST(int k);
void rotation(Node_BST *node, string bf);
void update_bf(Node_BST *node);
int getHeight(Node_BST* node);
void show_BST(Node_BST* node) const;
friend class HashTable_CA;
};
class HashTable_CA {
BST* tab;
int size;
int capacity;
public:
HashTable_CA();
~HashTable_CA();
int hash(int k) const;
void insert(int v, int k);
void remove(int k);
void increase_capacity();
void show() const;
void clear();
int capacity_() const;
int size_() const;
};