-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathABR.h
43 lines (29 loc) · 997 Bytes
/
ABR.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
#ifndef ABR_H_INCLUDED
#define ABR_H_INCLUDED
#include <vector>
#include "Nodo.h"
class ABR {
protected:
Nodo* root;
Nodo* NIL; //NODO SENTINELLA
int size;
Nodo* add (Nodo* x);
Nodo* del (Nodo* a);
Nodo* cerca (Nodo* a, const int i);
public:
void stampa ( Nodo* a);
ABR () {NIL = new Nodo(); root = NIL; size = 0;}
ABR (int x) { NIL = new Nodo(); root = new Nodo(x,NIL,NIL,NIL); size=1; }
void liberaABR (Nodo* a);
virtual ~ABR() {liberaABR(root);}
Nodo* GetRoot() {return root;}
Nodo* GetNIL() {return NIL;}
Nodo* GetMin (Nodo* a);
Nodo* GetMax (Nodo* a);
int GetSize() {return size;}
virtual Nodo* ins (Nodo* &a) { return add (a);}
virtual Nodo* canc (Nodo* &a) { return del (a);}
bool esiste (const int i) { bool value = ((cerca (root, i) == NIL) ? 0 : 1); return value; }
void Print () {stampa(root);}
};
#endif // ABR_H_INCLUDED