-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNodoKD.h
64 lines (54 loc) · 1.3 KB
/
NodoKD.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
#ifndef __NODOKD__H__
#define __NODOKD__H__
#include <iostream>
#include <queue>
struct point {
float x;
float y;
float z;
point& operator = (const point &p) {
x = p.x;
y = p.y;
z = p.z;
return *this;
}
bool operator == (const point &p) const {
return (x == p.x && y == p.y && z==p.z);
}
friend std::ostream& operator << (std::ostream &o, const point &p) {
o << "(" << p.x << "," << p.y << "," << p.z <<")";
return o;
}
};
class NodoKD {
protected:
point dato;
NodoKD *hijoIzq;
NodoKD *hijoDer;
public:
//constructores
NodoKD();
NodoKD(point &val);
NodoKD(point &val, NodoKD *izq, NodoKD *der);
//destructor
~NodoKD();
//manipuladores del nodo
bool esHoja();
point& obtenerDato();
void fijarDato(point &val);
NodoKD* obtenerHijoIzq();
NodoKD* obtenerHijoDer();
void fijarHijoIzq(NodoKD *izq);
void fijarHijoDer(NodoKD *der);
//operaciones del arbol
void preOrden();
void inOrden();
void posOrden();
void nivelOrden();
bool insertar(point &val);
void cola(std::queue<int> &colita);
void cercano(point valoraux,float &resultado,point &valorfinal);
float distancia(float x1,float y1,float z1,float x2,float y2,float z2);
};
#endif // __NODOKD__H__
// eof - NodoKD.h