diff --git a/doc/cl/cromer/estructuras/Enlace.html b/doc/cl/cromer/estructuras/Enlace.html index a3735a7..a7bd3b3 100644 --- a/doc/cl/cromer/estructuras/Enlace.html +++ b/doc/cl/cromer/estructuras/Enlace.html @@ -106,7 +106,7 @@ var activeTableTab = "activeTableTab";
interface Enlace
-EnlaceNormal
y EnlaceCircular
.EnlaceNormal
y EnlaceCircular
.java.lang.Object
getPrevio()
-java.lang.Object
getSiguiente()
-void
setPrevio(java.lang.Object previo)
-void
setSiguiente(java.lang.Object siguiente)
-java.lang.Object getSiguiente()-
void setSiguiente(java.lang.Object siguiente)-
siguiente
- Object: El siguiente enlace nuevo.siguiente
- Object: El siguiente listaEnlace nuevo.java.lang.Object getPrevio()-
void setPrevio(java.lang.Object previo)-
previo
- Object: El enlace previo nuevo.previo
- Object: El listaEnlace previo nuevo.public final class EnlaceCircular
extends java.lang.Object
implements Enlace
-private EnlaceCircular
siguiente
-EnlaceCircular
getPrevio()
-EnlaceCircular
getSiguiente()
-void
setSiguiente(java.lang.Object siguiente)
-private EnlaceCircular siguiente-
public EnlaceCircular getSiguiente()-
getSiguiente
in interface Enlace
public void setSiguiente(java.lang.Object siguiente)-
setSiguiente
in interface Enlace
siguiente
- Object: El siguiente enlace nuevo de tipo EnlaceCircular
.siguiente
- Object: El siguiente listaEnlace nuevo de tipo EnlaceCircular
.public EnlaceCircular getPrevio()-
getPrevio
in interface Enlace
setPrevio
in interface Enlace
previo
- Object: El enlace previo nuevo de tipo EnlaceCircular
.previo
- Object: El listaEnlace previo nuevo de tipo EnlaceCircular
.public final class EnlaceNormal
extends java.lang.Object
implements Enlace
-private EnlaceNormal
previo
-private EnlaceNormal
siguiente
-EnlaceNormal
getPrevio()
-EnlaceNormal
getSiguiente()
-void
setPrevio(java.lang.Object previo)
-void
setSiguiente(java.lang.Object siguiente)
-private EnlaceNormal siguiente-
private EnlaceNormal previo-
public EnlaceNormal getSiguiente()-
getSiguiente
in interface Enlace
public void setSiguiente(java.lang.Object siguiente)-
setSiguiente
in interface Enlace
siguiente
- Object: El siguiente enlace nuevo de tipo EnlaceNormal
.siguiente
- Object: El siguiente listaEnlace nuevo de tipo EnlaceNormal
.public EnlaceNormal getPrevio()-
getPrevio
in interface Enlace
public void setPrevio(java.lang.Object previo)-
setPrevio
in interface Enlace
previo
- Object: El enlace previo nuevo de tipo EnlaceNormal
.previo
- Object: El listaEnlace previo nuevo de tipo EnlaceNormal
.private Enlace
lista
-boolean
eliminar(int llave)
-Enlace
getIndice(int indice)
-private Enlace lista-
llave
- int: La llave a buscar.public boolean eliminar(int llave)-
llave
- int: La llave a eliminar.public Enlace getIndice(int indice)-
indice
- int: El indice que desea ver.private Enlace
primer
-private Enlace
ultimo
-boolean
eliminar(int llave)
-Enlace
getIndice(int indice)
-private Enlace primer-
private Enlace ultimo-
llave
- int: La llave a buscar.public boolean eliminar(int llave)-
llave
- int: La llave a elminiar.public Enlace getIndice(int indice)-
indice
- int: El indice que desea ver.private void
dibujarDoble(Enlace enlace,
+dibujarDoble(Enlace listaEnlace,
boolean primer)
Dibujarlo con dos flechas.
private void
dibujarSimple(Enlace enlace,
+dibujarSimple(Enlace listaEnlace,
boolean sinFlecha)
Dibujarlo con una flecha.
@@ -526,34 +526,34 @@ implements javafx.fxml.Initializable
Crear una nueva lista enlazada.
-
+
-
dibujarSimple
-private void dibujarSimple(Enlace enlace,
+private void dibujarSimple(Enlace listaEnlace,
boolean sinFlecha)
Dibujarlo con una flecha.
- Parameters:
-enlace
- Enlace: El enlace que tiene la llave y valor.
+listaEnlace
- Enlace: El listaEnlace que tiene la llave y valor.
sinFlecha
- boolean: Verdad si necesita dibujar una flecha.
-
+
-
dibujarDoble
-private void dibujarDoble(Enlace enlace,
+private void dibujarDoble(Enlace listaEnlace,
boolean primer)
Dibujarlo con dos flechas.
- Parameters:
-enlace
- Enlace: El enlace que tiene la llave y valor.
+listaEnlace
- Enlace: El listaEnlace que tiene la llave y valor.
primer
- boolean: Verdad si es el primer elemento de la lista.
diff --git a/doc/cl/cromer/estructuras/class-use/Enlace.html b/doc/cl/cromer/estructuras/class-use/Enlace.html
index b633f6b..c1f334c 100644
--- a/doc/cl/cromer/estructuras/class-use/Enlace.html
+++ b/doc/cl/cromer/estructuras/class-use/Enlace.html
@@ -4,7 +4,7 @@
-Uses of Interface cl.cromer.estructuras.Enlace
+Uses of Interface cl.cromer.estructuras.ListaEnlace
@@ -13,7 +13,7 @@
@@ -70,7 +70,7 @@
-Uses of Class
cl.cromer.estructuras.EnlaceCircular
+Uses of Class
cl.cromer.estructuras.ListaEnlaceCircular
@@ -90,7 +90,7 @@
private EnlaceCircular
EnlaceCircular.siguiente
-El siguiente enlace.
+El siguiente listaEnlace.
@@ -105,13 +105,13 @@
EnlaceCircular
EnlaceCircular.getPrevio()
-Devolver el enlace previo.
+Devolver el listaEnlace previo.
EnlaceCircular
EnlaceCircular.getSiguiente()
-Devolver el siguiente enlace.
+Devolver el siguiente listaEnlace.
diff --git a/doc/cl/cromer/estructuras/class-use/EnlaceNormal.html b/doc/cl/cromer/estructuras/class-use/EnlaceNormal.html
index dcbfda6..5fa4d6e 100644
--- a/doc/cl/cromer/estructuras/class-use/EnlaceNormal.html
+++ b/doc/cl/cromer/estructuras/class-use/EnlaceNormal.html
@@ -4,7 +4,7 @@
-Uses of Class cl.cromer.estructuras.EnlaceNormal
+Uses of Class cl.cromer.estructuras.ListaEnlaceNormal
@@ -70,7 +70,7 @@
-Uses of Class
cl.cromer.estructuras.EnlaceNormal
+Uses of Class
cl.cromer.estructuras.ListaEnlaceNormal
@@ -90,13 +90,13 @@
private EnlaceNormal
EnlaceNormal.previo
-El enlace previo por doble enlazada.
+El listaEnlace previo por doble enlazada.
private EnlaceNormal
EnlaceNormal.siguiente
-El siguiente enlace.
+El siguiente listaEnlace.
@@ -111,13 +111,13 @@
EnlaceNormal
EnlaceNormal.getPrevio()
-Devolver el enlace previo.
+Devolver el listaEnlace previo.
EnlaceNormal
EnlaceNormal.getSiguiente()
-Devolver el siguiente enlace.
+Devolver el siguiente listaEnlace.
diff --git a/doc/cl/cromer/estructuras/package-summary.html b/doc/cl/cromer/estructuras/package-summary.html
index bf0193b..41eb468 100644
--- a/doc/cl/cromer/estructuras/package-summary.html
+++ b/doc/cl/cromer/estructuras/package-summary.html
@@ -85,7 +85,7 @@
Enlace
-Esta interfaz es para los 2 tipos de enlace, EnlaceNormal
y EnlaceCircular
.
+Esta interfaz es para los 2 tipos de listaEnlace, EnlaceNormal
y EnlaceCircular
.
@@ -144,13 +144,13 @@
EnlaceCircular
-Esta clase es de tipo de enlace circular.
+Esta clase es de tipo de listaEnlace circular.
EnlaceNormal
-Esta clase es de tipo de enlace normal.
+Esta clase es de tipo de listaEnlace normal.
diff --git a/doc/cl/cromer/estructuras/package-use.html b/doc/cl/cromer/estructuras/package-use.html
index 6fb8d22..20fd3c8 100644
--- a/doc/cl/cromer/estructuras/package-use.html
+++ b/doc/cl/cromer/estructuras/package-use.html
@@ -105,17 +105,17 @@
Enlace
-Esta interfaz es para los 2 tipos de enlace, EnlaceNormal
y EnlaceCircular
.
+Esta interfaz es para los 2 tipos de listaEnlace, EnlaceNormal
y EnlaceCircular
.
EnlaceCircular
-Esta clase es de tipo de enlace circular.
+Esta clase es de tipo de listaEnlace circular.
EnlaceNormal
-Esta clase es de tipo de enlace normal.
+Esta clase es de tipo de listaEnlace normal.
diff --git a/doc/index-all.html b/doc/index-all.html
index 2af95ee..3a52bea 100644
--- a/doc/index-all.html
+++ b/doc/index-all.html
@@ -511,11 +511,11 @@
-
Destacar un elemento
-- dibujarDoble(Enlace, boolean) - Method in class cl.cromer.estructuras.ListaEnlazdaController
+- dibujarDoble(Enlace, boolean) - Method in class cl.cromer.estructuras.ListaEnlazdaController
-
Dibujarlo con dos flechas.
-- dibujarSimple(Enlace, boolean) - Method in class cl.cromer.estructuras.ListaEnlazdaController
+- dibujarSimple(Enlace, boolean) - Method in class cl.cromer.estructuras.ListaEnlazdaController
-
Dibujarlo con una flecha.
@@ -543,19 +543,19 @@
- eliminar(int) - Method in class cl.cromer.estructuras.ListaEnlazada
-
-Eliminar un enlace de la lista.
+Eliminar un listaEnlace de la lista.
- eliminar(int) - Method in class cl.cromer.estructuras.ListaEnlazadaCircular
-
-Eliminar un enlace de la lista.
+Eliminar un listaEnlace de la lista.
- Enlace - Interface in cl.cromer.estructuras
-
-Esta interfaz es para los 2 tipos de enlace,
EnlaceNormal
y EnlaceCircular
.
+Esta interfaz es para los 2 tipos de listaEnlace, EnlaceNormal
y EnlaceCircular
.
- EnlaceCircular - Class in cl.cromer.estructuras
-
-Esta clase es de tipo de enlace circular.
+Esta clase es de tipo de listaEnlace circular.
- EnlaceCircular() - Constructor for class cl.cromer.estructuras.EnlaceCircular
-
@@ -563,7 +563,7 @@
- EnlaceNormal - Class in cl.cromer.estructuras
-
-Esta clase es de tipo de enlace normal.
+Esta clase es de tipo de listaEnlace normal.
- EnlaceNormal() - Constructor for class cl.cromer.estructuras.EnlaceNormal
-
@@ -667,11 +667,11 @@
- getIndice(int) - Method in class cl.cromer.estructuras.ListaEnlazada
-
-Devolver un enlace con su llave y valor.
+Devolver un listaEnlace con su llave y valor.
- getIndice(int) - Method in class cl.cromer.estructuras.ListaEnlazadaCircular
-
-Devolver un enlace con su llave y valor.
+Devolver un listaEnlace con su llave y valor.
- getIndice(int) - Method in class cl.cromer.estructuras.Pila
-
@@ -701,15 +701,15 @@
-
- getPrevio() - Method in interface cl.cromer.estructuras.Enlace
-
-Devolver el enlace previo.
+Devolver el listaEnlace previo.
- getPrevio() - Method in class cl.cromer.estructuras.EnlaceCircular
-
-Devolver el enlace previo.
+Devolver el listaEnlace previo.
- getPrevio() - Method in class cl.cromer.estructuras.EnlaceNormal
-
-Devolver el enlace previo.
+Devolver el listaEnlace previo.
- getPunteroIzquerda() - Method in class cl.cromer.estructuras.Array.ParticionarResult
-
@@ -721,15 +721,15 @@
- getSiguiente() - Method in interface cl.cromer.estructuras.Enlace
-
-Devolver el siguente enlace.
+Devolver el siguente listaEnlace.
- getSiguiente() - Method in class cl.cromer.estructuras.EnlaceCircular
-
-Devolver el siguiente enlace.
+Devolver el siguiente listaEnlace.
- getSiguiente() - Method in class cl.cromer.estructuras.EnlaceNormal
-
-Devolver el siguiente enlace.
+Devolver el siguiente listaEnlace.
- getTexto() - Method in class cl.cromer.estructuras.Colores
-
@@ -973,7 +973,7 @@
- lista - Variable in class cl.cromer.estructuras.ListaEnlazada
-
-El enlace principal de la lista.
+El listaEnlace principal de la lista.
- ListaEnlazada - Class in cl.cromer.estructuras
-
@@ -1294,11 +1294,11 @@
- previo - Variable in class cl.cromer.estructuras.EnlaceNormal
-
-El enlace previo por doble enlazada.
+El listaEnlace previo por doble enlazada.
- primer - Variable in class cl.cromer.estructuras.ListaEnlazadaCircular
-
-El primer enlace.
+El primer listaEnlace.
- punteroIzquerda - Variable in class cl.cromer.estructuras.Array.ParticionarResult
-
@@ -1504,7 +1504,7 @@
- setPrevio(Object) - Method in interface cl.cromer.estructuras.Enlace
-
-Cambiar el previo enlace.
+Cambiar el previo listaEnlace.
- setPrevio(Object) - Method in class cl.cromer.estructuras.EnlaceCircular
-
@@ -1512,19 +1512,19 @@
- setPrevio(Object) - Method in class cl.cromer.estructuras.EnlaceNormal
-
-Cambiar el previo enlace.
+Cambiar el previo listaEnlace.
- setSiguiente(Object) - Method in interface cl.cromer.estructuras.Enlace
-
-Cambiar el siguiente enlace.
+Cambiar el siguiente listaEnlace.
- setSiguiente(Object) - Method in class cl.cromer.estructuras.EnlaceCircular
-
-Cambiar el siguiente enlace.
+Cambiar el siguiente listaEnlace.
- setSiguiente(Object) - Method in class cl.cromer.estructuras.EnlaceNormal
-
-Cambiar el siguiente enlace.
+Cambiar el siguiente listaEnlace.
- setTipo(int) - Method in class cl.cromer.estructuras.ListaEnlazada
-
@@ -1546,11 +1546,11 @@
-
- siguiente - Variable in class cl.cromer.estructuras.EnlaceCircular
-
-El siguiente enlace.
+El siguiente listaEnlace.
- siguiente - Variable in class cl.cromer.estructuras.EnlaceNormal
-
-El siguiente enlace.
+El siguiente listaEnlace.
- siguinteColor() - Method in class cl.cromer.estructuras.Colores
-
@@ -1678,7 +1678,7 @@
- ultimo - Variable in class cl.cromer.estructuras.ListaEnlazadaCircular
-
-El ultimo enlace.
+El ultimo listaEnlace.
diff --git a/doc/index-files/index-10.html b/doc/index-files/index-10.html
index f02ff1e..0863926 100644
--- a/doc/index-files/index-10.html
+++ b/doc/index-files/index-10.html
@@ -76,7 +76,7 @@
- lista - Variable in class cl.cromer.estructuras.ListaEnlazada
-
-El enlace principal de la lista.
+El listaEnlace principal de la lista.
- ListaEnlazada - Class in cl.cromer.estructuras
-
diff --git a/doc/index-files/index-14.html b/doc/index-files/index-14.html
index 3e584ce..fdf89a2 100644
--- a/doc/index-files/index-14.html
+++ b/doc/index-files/index-14.html
@@ -128,11 +128,11 @@
- previo - Variable in class cl.cromer.estructuras.EnlaceNormal
-
-El enlace previo por doble enlazada.
+El listaEnlace previo por doble enlazada.
- primer - Variable in class cl.cromer.estructuras.ListaEnlazadaCircular
-
-El primer enlace.
+El primer listaEnlace.
- punteroIzquerda - Variable in class cl.cromer.estructuras.Array.ParticionarResult
-
diff --git a/doc/index-files/index-17.html b/doc/index-files/index-17.html
index 414a6ef..89fd5c2 100644
--- a/doc/index-files/index-17.html
+++ b/doc/index-files/index-17.html
@@ -166,7 +166,7 @@
- setPrevio(Object) - Method in interface cl.cromer.estructuras.Enlace
-
-Cambiar el previo enlace.
+Cambiar el previo listaEnlace.
- setPrevio(Object) - Method in class cl.cromer.estructuras.EnlaceCircular
-
@@ -174,19 +174,19 @@
- setPrevio(Object) - Method in class cl.cromer.estructuras.EnlaceNormal
-
-Cambiar el previo enlace.
+Cambiar el previo listaEnlace.
- setSiguiente(Object) - Method in interface cl.cromer.estructuras.Enlace
-
-Cambiar el siguiente enlace.
+Cambiar el siguiente listaEnlace.
- setSiguiente(Object) - Method in class cl.cromer.estructuras.EnlaceCircular
-
-Cambiar el siguiente enlace.
+Cambiar el siguiente listaEnlace.
- setSiguiente(Object) - Method in class cl.cromer.estructuras.EnlaceNormal
-
-Cambiar el siguiente enlace.
+Cambiar el siguiente listaEnlace.
- setTipo(int) - Method in class cl.cromer.estructuras.ListaEnlazada
-
@@ -208,11 +208,11 @@
-
- siguiente - Variable in class cl.cromer.estructuras.EnlaceCircular
-
-El siguiente enlace.
+El siguiente listaEnlace.
- siguiente - Variable in class cl.cromer.estructuras.EnlaceNormal
-
-El siguiente enlace.
+El siguiente listaEnlace.
- siguinteColor() - Method in class cl.cromer.estructuras.Colores
-
diff --git a/doc/index-files/index-19.html b/doc/index-files/index-19.html
index 0827755..05e9dea 100644
--- a/doc/index-files/index-19.html
+++ b/doc/index-files/index-19.html
@@ -76,7 +76,7 @@
- ultimo - Variable in class cl.cromer.estructuras.ListaEnlazadaCircular
-
-El ultimo enlace.
+El ultimo listaEnlace.
A B C D E F G H I L M N O P Q R S T U V
diff --git a/doc/index-files/index-4.html b/doc/index-files/index-4.html
index 4c05d1b..f54cfe7 100644
--- a/doc/index-files/index-4.html
+++ b/doc/index-files/index-4.html
@@ -90,11 +90,11 @@
-
Destacar un elemento
- - dibujarDoble(Enlace, boolean) - Method in class cl.cromer.estructuras.ListaEnlazdaController
+- dibujarDoble(Enlace, boolean) - Method in class cl.cromer.estructuras.ListaEnlazdaController
-
Dibujarlo con dos flechas.
-- dibujarSimple(Enlace, boolean) - Method in class cl.cromer.estructuras.ListaEnlazdaController
+- dibujarSimple(Enlace, boolean) - Method in class cl.cromer.estructuras.ListaEnlazdaController
-
Dibujarlo con una flecha.
diff --git a/doc/index-files/index-5.html b/doc/index-files/index-5.html
index fa40afb..995b6e0 100644
--- a/doc/index-files/index-5.html
+++ b/doc/index-files/index-5.html
@@ -84,19 +84,19 @@
- eliminar(int) - Method in class cl.cromer.estructuras.ListaEnlazada
-
-Eliminar un enlace de la lista.
+Eliminar un listaEnlace de la lista.
- eliminar(int) - Method in class cl.cromer.estructuras.ListaEnlazadaCircular
-
-Eliminar un enlace de la lista.
+Eliminar un listaEnlace de la lista.
- Enlace - Interface in cl.cromer.estructuras
-
-Esta interfaz es para los 2 tipos de enlace,
EnlaceNormal
y EnlaceCircular
.
+Esta interfaz es para los 2 tipos de listaEnlace, EnlaceNormal
y EnlaceCircular
.
- EnlaceCircular - Class in cl.cromer.estructuras
-
-Esta clase es de tipo de enlace circular.
+Esta clase es de tipo de listaEnlace circular.
- EnlaceCircular() - Constructor for class cl.cromer.estructuras.EnlaceCircular
-
@@ -104,7 +104,7 @@
- EnlaceNormal - Class in cl.cromer.estructuras
-
-Esta clase es de tipo de enlace normal.
+Esta clase es de tipo de listaEnlace normal.
- EnlaceNormal() - Constructor for class cl.cromer.estructuras.EnlaceNormal
-
diff --git a/doc/index-files/index-7.html b/doc/index-files/index-7.html
index 0a779f9..aae84cc 100644
--- a/doc/index-files/index-7.html
+++ b/doc/index-files/index-7.html
@@ -156,11 +156,11 @@
- getIndice(int) - Method in class cl.cromer.estructuras.ListaEnlazada
-
-Devolver un enlace con su llave y valor.
+Devolver un listaEnlace con su llave y valor.
- getIndice(int) - Method in class cl.cromer.estructuras.ListaEnlazadaCircular
-
-Devolver un enlace con su llave y valor.
+Devolver un listaEnlace con su llave y valor.
- getIndice(int) - Method in class cl.cromer.estructuras.Pila
-
@@ -190,15 +190,15 @@
-
- getPrevio() - Method in interface cl.cromer.estructuras.Enlace
-
-Devolver el enlace previo.
+Devolver el listaEnlace previo.
- getPrevio() - Method in class cl.cromer.estructuras.EnlaceCircular
-
-Devolver el enlace previo.
+Devolver el listaEnlace previo.
- getPrevio() - Method in class cl.cromer.estructuras.EnlaceNormal
-
-Devolver el enlace previo.
+Devolver el listaEnlace previo.
- getPunteroIzquerda() - Method in class cl.cromer.estructuras.Array.ParticionarResult
-
@@ -210,15 +210,15 @@
- getSiguiente() - Method in interface cl.cromer.estructuras.Enlace
-
-Devolver el siguente enlace.
+Devolver el siguente listaEnlace.
- getSiguiente() - Method in class cl.cromer.estructuras.EnlaceCircular
-
-Devolver el siguiente enlace.
+Devolver el siguiente listaEnlace.
- getSiguiente() - Method in class cl.cromer.estructuras.EnlaceNormal
-
-Devolver el siguiente enlace.
+Devolver el siguiente listaEnlace.
- getTexto() - Method in class cl.cromer.estructuras.Colores
-
diff --git a/src/cl/cromer/estructuras/Arbol.java b/src/cl/cromer/estructuras/Arbol.java
new file mode 100644
index 0000000..e41cae1
--- /dev/null
+++ b/src/cl/cromer/estructuras/Arbol.java
@@ -0,0 +1,125 @@
+package cl.cromer.estructuras;
+
+public class Arbol {
+ private ArbolNodo arbol;
+ private int size;
+ private int altura;
+ private int ancho;
+
+ public enum PrimerLado {
+ IZQUERDA,
+ DERECHA
+ }
+
+ public Arbol() {
+ this.arbol = null;
+ this.altura = 0;
+ this.ancho = 0;
+ }
+
+ public boolean insertar(int valor) {
+ if (this.arbol == null) {
+ arbol = new ArbolNodo(valor);
+ arbol.setY(1);
+ arbol.setX(1);
+ ancho = 1;
+ altura = 1;
+ return true;
+ }
+ else {
+ PrimerLado primerLado = null;
+ ArbolNodo nuevo = new ArbolNodo(valor);
+ ArbolNodo actual = arbol;
+ ArbolNodo padre;
+ while (true) {
+ padre = actual;
+ if (valor == actual.getValor()) {
+ // Ya existe.
+ return false;
+ }
+ else if (valor < actual.getValor()) {
+ // Izquerda
+ if (primerLado == null) {
+ primerLado = PrimerLado.IZQUERDA;
+ nuevo.setX(1);
+ }
+ else {
+ nuevo.setX(nuevo.getX() + 1);
+ }
+ nuevo.setY(nuevo.getY() + 1);
+ actual = actual.getIzquerda();
+ if (actual == null) {
+ padre.setIzquerda(nuevo);
+ size++;
+ if (primerLado == PrimerLado.IZQUERDA) {
+ ancho++;
+ }
+ setAltura(getAlturaRecursivo(arbol));
+ return true;
+ }
+ }
+ else {
+ // Derecha
+ if (primerLado == null) {
+ primerLado = PrimerLado.DERECHA;
+ nuevo.setX(1);
+ }
+ else {
+ nuevo.setX(nuevo.getX() + 1);
+ }
+ nuevo.setY(nuevo.getY() + 1);
+ actual = actual.getDerecha();
+ if (actual == null) {
+ padre.setDerecha(nuevo);
+ size++;
+ if (primerLado == PrimerLado.DERECHA) {
+ ancho++;
+ }
+ setAltura(getAlturaRecursivo(arbol));
+ return true;
+ }
+ }
+ }
+ }
+ }
+
+ public ArbolNodo getArbol() {
+ return arbol;
+ }
+
+ public int size() {
+ return size;
+ }
+
+ public int getAltura() {
+ return altura;
+ }
+
+ public void setAltura(int altura) {
+ this.altura = altura;
+ }
+
+ public int getAncho() {
+ return ancho;
+ }
+
+ public void setAncho(int ancho) {
+ this.ancho = ancho;
+ }
+
+ public int getAlturaRecursivo(ArbolNodo nodo) {
+ if (nodo == null) {
+ return 0;
+ }
+ else {
+ int alturaIzquerda = getAlturaRecursivo(nodo.getIzquerda());
+ int alturaDercha = getAlturaRecursivo(nodo.getDerecha());
+ if (alturaIzquerda > alturaDercha) {
+ return (alturaIzquerda + 1);
+ }
+ else {
+ return (alturaDercha + 1);
+ }
+ }
+ }
+}
diff --git a/src/cl/cromer/estructuras/ArbolController.java b/src/cl/cromer/estructuras/ArbolController.java
new file mode 100644
index 0000000..953bade
--- /dev/null
+++ b/src/cl/cromer/estructuras/ArbolController.java
@@ -0,0 +1,205 @@
+package cl.cromer.estructuras;
+
+import javafx.fxml.FXML;
+import javafx.fxml.Initializable;
+import javafx.scene.Node;
+import javafx.scene.Scene;
+import javafx.scene.layout.ColumnConstraints;
+import javafx.scene.layout.GridPane;
+import javafx.scene.layout.VBox;
+import javafx.scene.text.Text;
+
+import java.net.URL;
+import java.util.Queue;
+import java.util.ResourceBundle;
+import java.util.Scanner;
+import java.util.Stack;
+import java.util.logging.Level;
+
+/**
+ * Esta clase es para controlar todos la interfaz de Arbol.
+ *
+ * @author Chris Cromer
+ */
+public class ArbolController implements Initializable {
+ /**
+ * La caja para ingresar textos.
+ */
+ @FXML
+ private TextFieldLimited valorArbol;
+
+ /**
+ * Donde poner el contenido de array.
+ */
+ @FXML
+ private GridPane contenidoArbol;
+
+ /**
+ * Donde va el codigo a mostrar a la pantalla.
+ */
+ @FXML
+ private Text codigoArbol;
+
+ /**
+ * La escena donde está cosas graficas.
+ */
+ private Scene scene;
+
+ /**
+ * Donde está guardado los idiomas.
+ */
+ private ResourceBundle resourceBundle;
+
+ /**
+ * El arbol usado en la aplicación.
+ */
+ private Arbol arbol;
+
+ /**
+ * Grafico rectangulos.
+ */
+ private Grafico grafico;
+
+ /**
+ * Inicializar todos los datos y dibujar las graficas.
+ *
+ * @param location URL: El URL de fxml en uso.
+ * @param resourceBundle ResourceBundle: Tiene datos de idioma.
+ */
+ @Override
+ public void initialize(URL location, ResourceBundle resourceBundle) {
+ this.resourceBundle = resourceBundle;
+
+ arbol = null;
+ scene = null;
+
+ // TODO: Remove this
+ arbol = new Arbol();
+ arbol.insertar(5);
+ arbol.insertar(4);
+ arbol.insertar(3);
+ arbol.insertar(2);
+ arbol.insertar(1);
+ }
+
+ /**
+ * Insertar un valor al array y mostrar el codigo en la pantalla.
+ */
+ @FXML
+ protected void botonInsertar() {
+ if (scene == null) {
+ initializeArbol();
+ }
+
+ // Mostrar el codigo
+ /*String codigoTexto = new Scanner(getClass().getResourceAsStream("/cl/cromer/estructuras/code/array" + tipo + "/insertar")).useDelimiter("\\Z").next();
+ codigoArray.setText(codigoTexto);*/
+
+ /*if (valorArbol.getText() != null && ! valorArbol.getText().trim().equals("")) {
+ try {
+ boolean exito = arbol.insertar(Integer.valueOf(valorArbol.getText()));
+ if (exito) {
+ valorArbol.setText("");
+ generarGrafico();
+ }
+ else {
+ Main.mostrarError(resourceBundle.getString("arbolValorExiste"), resourceBundle);
+ }
+ }
+ catch (NumberFormatException exception) {
+ // El error no es fatal, sigue
+ Logs.log(Level.WARNING, "No es tipo int.");
+ Main.mostrarError(resourceBundle.getString("arbolNoValor"), resourceBundle);
+ }
+ }
+ else {
+ Main.mostrarError(resourceBundle.getString("arbolNoValor"), resourceBundle);
+ }*/
+ generarGrafico();
+ }
+
+ /**
+ * Crear un arbol nuevo.
+ */
+ private void initializeArbol() {
+ scene = contenidoArbol.getScene();
+ // TODO: remove this
+ contenidoArbol.setGridLinesVisible(true);
+ grafico = new Grafico(scene);
+ //this.arbol = new Arbol();
+ ArbolTipos arbolTipos = (ArbolTipos) scene.getUserData();
+ }
+
+ /**
+ * Poner los valores en el grafico.
+ */
+ private void generarGrafico() {
+ grafico.removerDestacar();
+ Node node = contenidoArbol.getChildren().get(0);
+ contenidoArbol.getChildren().clear();
+ contenidoArbol.getChildren().add(0, node);
+
+ Text text;
+
+ int ancho = arbol.getAncho();
+ if (ancho % 2 == 0) {
+ ancho++;
+ }
+ for (int i = 0; i < arbol.getAltura(); i++) {
+ contenidoArbol.addRow(i);
+ for (int j = 0; j < ancho; j++) {
+ contenidoArbol.addColumn(j);
+ text = new Text();
+ text.setText(" ");
+ text.setId(j + "_" + i);
+ contenidoArbol.add(text, j, i);
+ }
+ }
+
+ int medio = ancho / 2;
+
+ ArbolNodo tempArbol = this.arbol.getArbol();
+ Stack globalStack = new Stack();
+ globalStack.push(tempArbol);
+ boolean filaVacio = false;
+ int x = medio;
+ int y = 0;
+ while (!filaVacio) {
+ Stack localStack = new Stack();
+ filaVacio = true;
+
+ text = new Text();
+ text.setText(" ");
+ text.setId(x + "_" + y);
+ contenidoArbol.add(text, x, y);
+
+ while (!globalStack.isEmpty()) {
+ ArbolNodo temp = (ArbolNodo) globalStack.pop();
+ if (temp != null) {
+ //System.out.print(temp.iData);
+ text = new Text();
+ text.setText(String.valueOf(temp.getValor()));
+ text.setId(x + "_" + y);
+ contenidoArbol.add(text, x, y);
+ localStack.push(temp.getIzquerda());
+ localStack.push(temp.getDerecha());
+
+ if(temp.getIzquerda() != null ||
+ temp.getDerecha() != null)
+ filaVacio = false;
+ }
+ else {
+ System.out.print("--");
+ localStack.push(null);
+ localStack.push(null);
+ }
+ x++;
+ }
+ y++;
+ x = 0;
+ // Next level
+ while(!localStack.isEmpty())
+ globalStack.push( localStack.pop() );
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/cl/cromer/estructuras/ArbolNodo.java b/src/cl/cromer/estructuras/ArbolNodo.java
new file mode 100644
index 0000000..03cb771
--- /dev/null
+++ b/src/cl/cromer/estructuras/ArbolNodo.java
@@ -0,0 +1,73 @@
+package cl.cromer.estructuras;
+
+final public class ArbolNodo {
+ private ArbolNodo izquerda;
+ private ArbolNodo derecha;
+ private int valor;
+ private int y;
+ private int x;
+ private Desde desde;
+
+ public ArbolNodo(int valor) {
+ this.izquerda = null;
+ this.derecha = null;
+ this.valor = valor;
+ this.y = 0;
+ this.x = 0;
+ this.desde = Desde.RAIZ;
+ }
+
+ public ArbolNodo getIzquerda() {
+ return izquerda;
+ }
+
+ public void setIzquerda(ArbolNodo izquerda) {
+ this.izquerda = izquerda;
+ }
+
+ public ArbolNodo getDerecha() {
+ return derecha;
+ }
+
+ public void setDerecha(ArbolNodo derecha) {
+ this.derecha = derecha;
+ }
+
+ public int getValor() {
+ return valor;
+ }
+
+ public int getY() {
+ return y;
+ }
+
+ public void setY(int y) {
+ if (y >= 0) {
+ this.y = y;
+ }
+ }
+
+ public int getX() {
+ return x;
+ }
+
+ public void setX(int x) {
+ if (x >= 0) {
+ this.x = x;
+ }
+ }
+
+ public Desde getDesde() {
+ return desde;
+ }
+
+ public void setDesde(Desde desde) {
+ this.desde = desde;
+ }
+
+ public enum Desde {
+ RAIZ,
+ IQUERDA,
+ DERECHA
+ }
+}
diff --git a/src/cl/cromer/estructuras/Colores.java b/src/cl/cromer/estructuras/Colores.java
index 7fe4aa5..b069fc9 100644
--- a/src/cl/cromer/estructuras/Colores.java
+++ b/src/cl/cromer/estructuras/Colores.java
@@ -28,6 +28,11 @@ public class Colores {
*/
private Color fondo;
+ /**
+ * El color de border actual.
+ */
+ private Color border;
+
/**
* Inicializar el primer color.
*/
@@ -44,36 +49,43 @@ public class Colores {
color = 2;
texto = Color.WHITE;
fondo = Color.RED;
+ border = Color.BLACK;
break;
case 2:
color = 3;
texto = Color.BLACK;
fondo = Color.WHITE;
+ border = Color.BLACK;
break;
case 3:
color = 4;
texto = Color.BLACK;
fondo = Color.PINK;
+ border = Color.BLACK;
break;
case 4:
color = 5;
texto = Color.BLACK;
fondo = Color.YELLOW;
+ border = Color.BLACK;
break;
case 5:
color = 6;
texto = Color.BLACK;
fondo = Color.GREEN;
+ border = Color.BLACK;
break;
case 6:
color = 7;
texto = Color.BLACK;
fondo = Color.ORANGE;
+ border = Color.BLACK;
break;
default:
color = 1;
texto = Color.WHITE;
fondo = Color.BLUE;
+ border = Color.BLACK;
}
}
@@ -94,4 +106,13 @@ public class Colores {
public Color getFondo() {
return fondo;
}
+
+ /**
+ * Devolver el color del border actual.
+ *
+ * @return Color: Color del border.
+ */
+ public Color getBorder() {
+ return border;
+ }
}
diff --git a/src/cl/cromer/estructuras/Grafico.java b/src/cl/cromer/estructuras/Grafico.java
index 5f8304d..e967c08 100644
--- a/src/cl/cromer/estructuras/Grafico.java
+++ b/src/cl/cromer/estructuras/Grafico.java
@@ -172,7 +172,7 @@ public class Grafico {
rectangle.setHeight(40);
rectangle.setWidth(40);
rectangle.setFill(colores.getFondo());
- rectangle.setStroke(Color.BLACK);
+ rectangle.setStroke(colores.getBorder());
rectangle.setId("caja_" + label);
Text text = new Text();
text.setId("texto_" + label);
@@ -197,7 +197,7 @@ public class Grafico {
rectangle.setHeight(40);
rectangle.setWidth(40);
rectangle.setFill(colores.getFondo());
- rectangle.setStroke(Color.BLACK);
+ rectangle.setStroke(colores.getBorder());
rectangle.setId("caja_" + label);
Text text = new Text();
text.setId("texto_" + label);
@@ -209,6 +209,22 @@ public class Grafico {
return stackPane;
}
+ public static StackPane crearCirculo(Colores colores, String label) {
+ Circle circle = new Circle();
+ circle.setRadius(20);
+ circle.setFill(colores.getFondo());
+ circle.setStroke(colores.getBorder());
+ circle.setId("circulo_" + label);
+
+ Text text = new Text();
+ text.setId("texto_" + label);
+ text.setStroke(colores.getTexto());
+
+ StackPane stackPane = new StackPane();
+ stackPane.getChildren().addAll(circle, text);
+ return stackPane;
+ }
+
/**
* Crear 3 rectangulos.
*
@@ -222,7 +238,7 @@ public class Grafico {
rectangle.setHeight(40);
rectangle.setWidth(40);
rectangle.setFill(colores.getFondo());
- rectangle.setStroke(Color.BLACK);
+ rectangle.setStroke(colores.getBorder());
rectangle.setId("indice_caja_" + label);
Text text = new Text();
text.setId("indice_texto_" + label);
@@ -235,7 +251,7 @@ public class Grafico {
rectangle.setHeight(40);
rectangle.setWidth(120);
rectangle.setFill(colores.getFondo());
- rectangle.setStroke(Color.BLACK);
+ rectangle.setStroke(colores.getBorder());
rectangle.setId("llave_caja_" + label);
text = new Text();
text.setId("llave_texto_" + label);
@@ -248,7 +264,7 @@ public class Grafico {
rectangle.setHeight(40);
rectangle.setWidth(40);
rectangle.setFill(colores.getFondo());
- rectangle.setStroke(Color.BLACK);
+ rectangle.setStroke(colores.getBorder());
rectangle.setId("valor_caja_" + label);
text = new Text();
text.setId("valor_texto_" + label);
diff --git a/src/cl/cromer/estructuras/Enlace.java b/src/cl/cromer/estructuras/ListaEnlace.java
similarity index 85%
rename from src/cl/cromer/estructuras/Enlace.java
rename to src/cl/cromer/estructuras/ListaEnlace.java
index ba96b66..17e1681 100644
--- a/src/cl/cromer/estructuras/Enlace.java
+++ b/src/cl/cromer/estructuras/ListaEnlace.java
@@ -1,11 +1,11 @@
package cl.cromer.estructuras;
/**
- * Esta interfaz es para los 2 tipos de enlace, {@link EnlaceNormal} y {@link EnlaceCircular}.
+ * Esta interfaz es para los 2 tipos de enlace, {@link ListaEnlaceNormal} y {@link ListaEnlaceCircular}.
*
* @author Chris Cromer
*/
-interface Enlace {
+interface ListaEnlace {
/**
* Devolver la llave.
*
diff --git a/src/cl/cromer/estructuras/EnlaceCircular.java b/src/cl/cromer/estructuras/ListaEnlaceCircular.java
similarity index 65%
rename from src/cl/cromer/estructuras/EnlaceCircular.java
rename to src/cl/cromer/estructuras/ListaEnlaceCircular.java
index 2c570f7..fac1318 100644
--- a/src/cl/cromer/estructuras/EnlaceCircular.java
+++ b/src/cl/cromer/estructuras/ListaEnlaceCircular.java
@@ -5,7 +5,7 @@ package cl.cromer.estructuras;
*
* @author Chris Cromer
*/
-final public class EnlaceCircular implements Enlace {
+final public class ListaEnlaceCircular implements ListaEnlace {
/**
* La llave.
*/
@@ -14,12 +14,12 @@ final public class EnlaceCircular implements Enlace {
/**
* El siguiente enlace.
*/
- private EnlaceCircular siguiente;
+ private ListaEnlaceCircular siguiente;
/**
* Incializar.
*/
- public EnlaceCircular() {
+ public ListaEnlaceCircular() {
siguiente = null;
}
@@ -44,34 +44,34 @@ final public class EnlaceCircular implements Enlace {
/**
* Devolver el siguiente enlace.
*
- * @return EnlaceCircular: El enlace a devolver.
+ * @return ListaEnlaceCircular: El enlace a devolver.
*/
- public EnlaceCircular getSiguiente() {
+ public ListaEnlaceCircular getSiguiente() {
return siguiente;
}
/**
* Cambiar el siguiente enlace.
*
- * @param siguiente Object: El siguiente enlace nuevo de tipo {@link EnlaceCircular}.
+ * @param siguiente Object: El siguiente enlace nuevo de tipo {@link ListaEnlaceCircular}.
*/
public void setSiguiente(Object siguiente) {
- this.siguiente = (EnlaceCircular) siguiente;
+ this.siguiente = (ListaEnlaceCircular) siguiente;
}
/**
* Devolver el enlace previo.
*
- * @return EnlaceCircular: El enlace previo.
+ * @return ListaEnlaceCircular: El enlace previo.
*/
- public EnlaceCircular getPrevio() {
+ public ListaEnlaceCircular getPrevio() {
return null;
}
/**
- * Dummy metodo para usar interface {@link Enlace}
+ * Dummy metodo para usar interface {@link ListaEnlace}
*
- * @param previo Object: El enlace previo nuevo de tipo {@link EnlaceCircular}.
+ * @param previo Object: El enlace previo nuevo de tipo {@link ListaEnlaceCircular}.
*/
public void setPrevio(Object previo) {
}
diff --git a/src/cl/cromer/estructuras/EnlaceNormal.java b/src/cl/cromer/estructuras/ListaEnlaceNormal.java
similarity index 67%
rename from src/cl/cromer/estructuras/EnlaceNormal.java
rename to src/cl/cromer/estructuras/ListaEnlaceNormal.java
index e0702e3..50cc06e 100644
--- a/src/cl/cromer/estructuras/EnlaceNormal.java
+++ b/src/cl/cromer/estructuras/ListaEnlaceNormal.java
@@ -5,7 +5,7 @@ package cl.cromer.estructuras;
*
* @author Chris Cromer
*/
-final public class EnlaceNormal implements Enlace {
+final public class ListaEnlaceNormal implements ListaEnlace {
/**
* La llave.
*/
@@ -14,17 +14,17 @@ final public class EnlaceNormal implements Enlace {
/**
* El siguiente enlace.
*/
- private EnlaceNormal siguiente;
+ private ListaEnlaceNormal siguiente;
/**
* El enlace previo por doble enlazada.
*/
- private EnlaceNormal previo;
+ private ListaEnlaceNormal previo;
/**
* Incializar.
*/
- public EnlaceNormal() {
+ public ListaEnlaceNormal() {
siguiente = null;
previo = null;
}
@@ -50,36 +50,36 @@ final public class EnlaceNormal implements Enlace {
/**
* Devolver el siguiente enlace.
*
- * @return EnlaceNormal: El enlace a devolver.
+ * @return ListaEnlaceNormal: El enlace a devolver.
*/
- public EnlaceNormal getSiguiente() {
+ public ListaEnlaceNormal getSiguiente() {
return siguiente;
}
/**
* Cambiar el siguiente enlace.
*
- * @param siguiente Object: El siguiente enlace nuevo de tipo {@link EnlaceNormal}.
+ * @param siguiente Object: El siguiente enlace nuevo de tipo {@link ListaEnlaceNormal}.
*/
public void setSiguiente(Object siguiente) {
- this.siguiente = (EnlaceNormal) siguiente;
+ this.siguiente = (ListaEnlaceNormal) siguiente;
}
/**
* Devolver el enlace previo.
*
- * @return EnlaceNormal: El enlace previo.
+ * @return ListaEnlaceNormal: El enlace previo.
*/
- public EnlaceNormal getPrevio() {
+ public ListaEnlaceNormal getPrevio() {
return previo;
}
/**
* Cambiar el previo enlace.
*
- * @param previo Object: El enlace previo nuevo de tipo {@link EnlaceNormal}.
+ * @param previo Object: El enlace previo nuevo de tipo {@link ListaEnlaceNormal}.
*/
public void setPrevio(Object previo) {
- this.previo = (EnlaceNormal) previo;
+ this.previo = (ListaEnlaceNormal) previo;
}
}
\ No newline at end of file
diff --git a/src/cl/cromer/estructuras/ListaEnlazada.java b/src/cl/cromer/estructuras/ListaEnlazada.java
index 2dbe5ab..846d90a 100644
--- a/src/cl/cromer/estructuras/ListaEnlazada.java
+++ b/src/cl/cromer/estructuras/ListaEnlazada.java
@@ -9,7 +9,7 @@ final public class ListaEnlazada {
/**
* El enlace principal de la lista.
*/
- private Enlace lista;
+ private ListaEnlace lista;
/**
* La cantidad de enlaces que están en la lista.
@@ -56,7 +56,7 @@ final public class ListaEnlazada {
public boolean insertar(int llave) {
if (buscar(llave) == null) {
// Crear una enlace y agregarla a la lista
- Enlace nuevo = new EnlaceNormal();
+ ListaEnlace nuevo = new ListaEnlaceNormal();
nuevo.setLlave(llave);
nuevo.setSiguiente(lista);
if (lista != null) {
@@ -82,14 +82,14 @@ final public class ListaEnlazada {
public boolean eliminar(int llave) {
if (lista != null) {
// La lista no es vacia
- Enlace lista = this.lista;
- Enlace previo = lista;
+ ListaEnlace lista = this.lista;
+ ListaEnlace previo = lista;
while (lista.getLlave() != llave) {
// Buscar hasta la llave es encontraddo
if (lista.getSiguiente() != null) {
// Buscar en la siguiente enlace
previo = lista;
- lista = (Enlace) lista.getSiguiente();
+ lista = (ListaEnlace) lista.getSiguiente();
}
else {
// No se encuentra
@@ -99,7 +99,7 @@ final public class ListaEnlazada {
// Se encontró
if (lista == this.lista) {
// Si es la primera enlace, cambiarla al siguiente enlace
- this.lista = (Enlace) this.lista.getSiguiente();
+ this.lista = (ListaEnlace) this.lista.getSiguiente();
if (this.lista.getPrevio() != null) {
this.lista.setPrevio(null);
}
@@ -122,17 +122,17 @@ final public class ListaEnlazada {
*
* @param llave int: La llave a buscar.
*
- * @return Enlace: El enlace que contiene la llave buscada.
+ * @return ListaEnlace: El enlace que contiene la llave buscada.
*/
- public Enlace buscar(int llave) {
+ public ListaEnlace buscar(int llave) {
if (this.lista != null) {
// La lista no es vacia
- Enlace lista = this.lista;
+ ListaEnlace lista = this.lista;
while (lista.getLlave() != llave) {
// Buscar hasta la llave es encontrado
if (lista.getSiguiente() != null) {
// Buscar en la siguiente enlace
- lista = (Enlace) lista.getSiguiente();
+ lista = (ListaEnlace) lista.getSiguiente();
}
else {
// No se encuentra
@@ -153,14 +153,14 @@ final public class ListaEnlazada {
*
* @param indice int: El indice que desea ver.
*
- * @return Enlace: El enlace a devolver.
+ * @return ListaEnlace: El enlace a devolver.
*/
- public Enlace getIndice(int indice) {
+ public ListaEnlace getIndice(int indice) {
if (lista != null && indice >= 0 && indice < size()) {
int i = size();
- Enlace lista = this.lista;
+ ListaEnlace lista = this.lista;
while (i > indice + 1) {
- lista = (Enlace) lista.getSiguiente();
+ lista = (ListaEnlace) lista.getSiguiente();
i--;
}
return lista;
diff --git a/src/cl/cromer/estructuras/ListaEnlazadaCircular.java b/src/cl/cromer/estructuras/ListaEnlazadaCircular.java
index 30feb81..f418601 100644
--- a/src/cl/cromer/estructuras/ListaEnlazadaCircular.java
+++ b/src/cl/cromer/estructuras/ListaEnlazadaCircular.java
@@ -9,12 +9,12 @@ final public class ListaEnlazadaCircular {
/**
* El primer enlace.
*/
- private Enlace primer;
+ private ListaEnlace primer;
/**
* El ultimo enlace.
*/
- private Enlace ultimo;
+ private ListaEnlace ultimo;
/**
* La cantidad de enlaces que hay.
@@ -61,16 +61,16 @@ final public class ListaEnlazadaCircular {
*/
public boolean insertar(int llave) {
if (buscar(llave) == null) {
- // Crear una enlace y agregarla a la lista
- Enlace enlace = new EnlaceCircular();
+ // Crear una listaEnlace y agregarla a la lista
+ ListaEnlace listaEnlace = new ListaEnlaceCircular();
if (primer == null) {
- ultimo = enlace;
+ ultimo = listaEnlace;
}
- enlace.setLlave(llave);
- enlace.setSiguiente(primer);
- primer = enlace;
+ listaEnlace.setLlave(llave);
+ listaEnlace.setSiguiente(primer);
+ primer = listaEnlace;
ultimo.setSiguiente(primer);
size++;
@@ -92,15 +92,15 @@ final public class ListaEnlazadaCircular {
public boolean eliminar(int llave) {
if (primer != null) {
// La lista no es vacia
- Enlace lista = this.primer;
- Enlace previo = lista;
+ ListaEnlace lista = this.primer;
+ ListaEnlace previo = lista;
int i = 0;
while (lista.getLlave() != llave && i < size()) {
// Buscar hasta la llave es encontraddo
if (lista.getSiguiente() != null) {
// Buscar en la siguiente enlace
previo = lista;
- lista = (Enlace) lista.getSiguiente();
+ lista = (ListaEnlace) lista.getSiguiente();
}
i++;
}
@@ -113,7 +113,7 @@ final public class ListaEnlazadaCircular {
// Se encontró
if (lista == this.primer) {
// Si es la primera enlace, cambiarla al sigueinte enlace
- this.primer = (Enlace) this.primer.getSiguiente();
+ this.primer = (ListaEnlace) this.primer.getSiguiente();
}
else {
// Sino cortar esta enlace de la lista
@@ -133,16 +133,16 @@ final public class ListaEnlazadaCircular {
*
* @param llave int: La llave a buscar.
*
- * @return Enlace: El enlace que contiene la llave.
+ * @return ListaEnlace: El enlace que contiene la llave.
*/
- public Enlace buscar(int llave) {
+ public ListaEnlace buscar(int llave) {
if (this.primer != null) {
// La lista no es vacia
- Enlace lista = this.primer;
+ ListaEnlace lista = this.primer;
int i = 0;
while (lista.getLlave() != llave && i < size()) {
// Buscar en la sigenute enlace hasta el final.
- lista = (Enlace) lista.getSiguiente();
+ lista = (ListaEnlace) lista.getSiguiente();
i++;
}
if (lista.getLlave() == llave) {
@@ -174,14 +174,14 @@ final public class ListaEnlazadaCircular {
*
* @param indice int: El indice que desea ver.
*
- * @return Enlace: El enlace a devolver.
+ * @return ListaEnlace: El enlace a devolver.
*/
- public Enlace getIndice(int indice) {
+ public ListaEnlace getIndice(int indice) {
if (primer != null && indice >= 0 && indice < size()) {
int i = size();
- Enlace lista = this.primer;
+ ListaEnlace lista = this.primer;
while (i > indice + 1) {
- lista = (Enlace) lista.getSiguiente();
+ lista = (ListaEnlace) lista.getSiguiente();
i--;
}
return lista;
diff --git a/src/cl/cromer/estructuras/ListaEnlazdaController.java b/src/cl/cromer/estructuras/ListaEnlazdaController.java
index 284eed5..3ae8df1 100644
--- a/src/cl/cromer/estructuras/ListaEnlazdaController.java
+++ b/src/cl/cromer/estructuras/ListaEnlazdaController.java
@@ -242,18 +242,18 @@ public class ListaEnlazdaController implements Initializable {
try {
if (valorLista.getText() != null && ! valorLista.getText().trim().equals("")) {
- Enlace enlace;
+ ListaEnlace listaEnlace;
if (listaEnlazadaTipos.getTipo() != ListaEnlazadaTipos.CIRCULAR) {
- enlace = listaEnlazada.buscar(Integer.valueOf(valorLista.getText()));
+ listaEnlace = listaEnlazada.buscar(Integer.valueOf(valorLista.getText()));
}
else {
- enlace = listaEnlazadaCircular.buscar(Integer.valueOf(valorLista.getText()));
+ listaEnlace = listaEnlazadaCircular.buscar(Integer.valueOf(valorLista.getText()));
}
- if (enlace != null) {
+ if (listaEnlace != null) {
generarGrafico();
grafico = new Grafico(scene);
- grafico.destacar("#caja_" + enlace.getLlave(), Grafico.RECTANGULO);
- grafico.destacar("#texto_" + enlace.getLlave(), Grafico.TEXTO);
+ grafico.destacar("#caja_" + listaEnlace.getLlave(), Grafico.RECTANGULO);
+ grafico.destacar("#texto_" + listaEnlace.getLlave(), Grafico.TEXTO);
}
else {
Main.mostrarError(resourceBundle.getString("listaNoEsta"), resourceBundle);
@@ -309,16 +309,16 @@ public class ListaEnlazdaController implements Initializable {
if (listaEnlazadaTipos.getTipo() != ListaEnlazadaTipos.CIRCULAR) {
for (int i = 0; i < listaEnlazada.size(); i++) {
- Enlace enlace = listaEnlazada.getIndice(i);
+ ListaEnlace listaEnlace = listaEnlazada.getIndice(i);
if (listaEnlazada.getTipo() == ListaEnlazadaTipos.SIMPLE) {
- dibujarSimple(enlace, false);
+ dibujarSimple(listaEnlace, false);
}
else if (listaEnlazada.getTipo() == ListaEnlazadaTipos.DOBLEMENTE_ENLAZADA) {
if (i != listaEnlazada.size() - 1) {
- dibujarDoble(enlace, (i == 0));
+ dibujarDoble(listaEnlace, (i == 0));
}
else {
- dibujarSimple(enlace, false);
+ dibujarSimple(listaEnlace, false);
}
}
colores.siguinteColor();
@@ -326,8 +326,8 @@ public class ListaEnlazdaController implements Initializable {
}
else {
for (int i = 0; i < listaEnlazadaCircular.size(); i++) {
- Enlace enlace = listaEnlazadaCircular.getIndice(i);
- dibujarSimple(enlace, (i == listaEnlazadaCircular.size() - 1));
+ ListaEnlace listaEnlace = listaEnlazadaCircular.getIndice(i);
+ dibujarSimple(listaEnlace, (i == listaEnlazadaCircular.size() - 1));
colores.siguinteColor();
}
if (listaEnlazadaCircular.size() > 0) {
@@ -353,12 +353,12 @@ public class ListaEnlazdaController implements Initializable {
/**
* Dibujarlo con una flecha.
*
- * @param enlace Enlace: El enlace que tiene la llave y valor.
+ * @param listaEnlace ListaEnlace: El listaEnlace que tiene la llave y valor.
* @param sinFlecha boolean: Verdad si necesita dibujar una flecha.
*/
- private void dibujarSimple(Enlace enlace, boolean sinFlecha) {
+ private void dibujarSimple(ListaEnlace listaEnlace, boolean sinFlecha) {
contenidoLista.getChildren().addAll(
- Grafico.crearCaja(colores, String.valueOf(enlace.getLlave()), String.valueOf(enlace.getLlave()))
+ Grafico.crearCaja(colores, String.valueOf(listaEnlace.getLlave()), String.valueOf(listaEnlace.getLlave()))
);
if (! sinFlecha) {
contenidoLista.getChildren().addAll(
@@ -371,10 +371,10 @@ public class ListaEnlazdaController implements Initializable {
/**
* Dibujarlo con dos flechas.
*
- * @param enlace Enlace: El enlace que tiene la llave y valor.
+ * @param listaEnlace ListaEnlace: El listaEnlace que tiene la llave y valor.
* @param primer boolean: Verdad si es el primer elemento de la lista.
*/
- private void dibujarDoble(Enlace enlace, boolean primer) {
+ private void dibujarDoble(ListaEnlace listaEnlace, boolean primer) {
if (primer) {
contenidoLista.getChildren().addAll(
Grafico.crearFlechaArriba(),
@@ -382,7 +382,7 @@ public class ListaEnlazdaController implements Initializable {
);
}
contenidoLista.getChildren().addAll(
- Grafico.crearCaja(colores, String.valueOf(enlace.getLlave()), String.valueOf(enlace.getLlave())),
+ Grafico.crearCaja(colores, String.valueOf(listaEnlace.getLlave()), String.valueOf(listaEnlace.getLlave())),
Grafico.crearFlechaArriba(),
Grafico.crearLineaVertical(),
Grafico.crearFlechaAbajo()
diff --git a/src/cl/cromer/estructuras/Main.java b/src/cl/cromer/estructuras/Main.java
index 709503e..064893a 100644
--- a/src/cl/cromer/estructuras/Main.java
+++ b/src/cl/cromer/estructuras/Main.java
@@ -28,7 +28,7 @@ public class Main extends Application {
/**
* Estado de depuración.
*/
- static final public boolean DEBUG = false;
+ static final public boolean DEBUG = true;
/**
* Crear el stage y la scene para la aplicación grafica.
@@ -50,6 +50,7 @@ public class Main extends Application {
catch (IOException exception) {
// Este error es fatal, hay que cerrar la aplicación.
Logs.log(Level.SEVERE, "No se pudo abrir el archivo de fxml.");
+ Logs.log(Level.SEVERE, exception.getMessage());
stage.close();
}
diff --git a/src/cl/cromer/estructuras/MenuController.java b/src/cl/cromer/estructuras/MenuController.java
index 1a468c4..773642e 100644
--- a/src/cl/cromer/estructuras/MenuController.java
+++ b/src/cl/cromer/estructuras/MenuController.java
@@ -213,6 +213,20 @@ public class MenuController extends VBox implements Initializable {
);
}
+ /**
+ * Click en Arbol General.
+ */
+ @FXML
+ protected void menuArbolGeneral() {
+ ArbolTipos arbolTipos = new ArbolTipos(ArbolTipos.GENERAL);
+ loadStage(
+ resourceBundle.getString("tituloCola"),
+ "/cl/cromer/estructuras/fxml/arbol.fxml",
+ "/cl/cromer/estructuras/css/main.css",
+ arbolTipos
+ );
+ }
+
/**
* Click en Hash Table.
*/
@@ -344,6 +358,7 @@ public class MenuController extends VBox implements Initializable {
catch (IOException exception) {
// Este error es fatal, hay que cerrar la aplicación.
Logs.log(Level.SEVERE, "No se pudo abrir el archivo de fxml.");
+ Logs.log(Level.SEVERE, exception.getMessage());
stage.close();
}
@@ -360,6 +375,7 @@ public class MenuController extends VBox implements Initializable {
catch (IOException exception) {
// Este error es fatal, hay que cerrar la aplicación.
Logs.log(Level.SEVERE, "No se pudo abrir el archivo de fxml.");
+ Logs.log(Level.SEVERE, exception.getMessage());
stage.close();
}
}
diff --git a/src/cl/cromer/estructuras/bundles/Idioma_en.properties b/src/cl/cromer/estructuras/bundles/Idioma_en.properties
index 756ff5d..df24b6a 100644
--- a/src/cl/cromer/estructuras/bundles/Idioma_en.properties
+++ b/src/cl/cromer/estructuras/bundles/Idioma_en.properties
@@ -86,7 +86,10 @@ pilaNoValor=Please input a numeric value.
colaLlena=Value not inserted because the queue is full.
colaVacia=The queue is empty.
colaNoValor=Please input a numeric value.
-tablaHashLleno=Key not inserted because hash table is full.
+arbolValorExiste=Value already exists.
+arbolNoEsta=Value does not exist.
+arbolNoValor=Please input a numeric value.
+tablaHashLleno=Key not inserted because the hash table is full.
tablaHashLlaveExiste=Key already exists.
tablaHashNoEsta=Key does not exist.
tablaHashNoLlave=Please input a key and a numeric value.
\ No newline at end of file
diff --git a/src/cl/cromer/estructuras/bundles/Idioma_es.properties b/src/cl/cromer/estructuras/bundles/Idioma_es.properties
index 670d446..3239503 100644
--- a/src/cl/cromer/estructuras/bundles/Idioma_es.properties
+++ b/src/cl/cromer/estructuras/bundles/Idioma_es.properties
@@ -85,6 +85,9 @@ pilaNoValor=Ingresar un valor num\u00E9rico por favor.
colaLlena=El valor no fue insertado porque la cola est\u00E1 llena.
colaVacia=La cola est\u00E1 vac\u00EDa.
colaNoValor=Ingresar un valor num\u00E9rico por favor.
+arbolValorExiste=El valor ya existe.
+arbolNoEsta=El valor no existe.
+arbolNoValor=Ingresar un valor num\u00E9rico por favor.
tablaHashLleno=La llave no fue insertado porque la tabla hash est\u00E1 lleno.
tablaHashLlaveExiste=La llave ya existe.
tablaHashNoEsta=La llave no existe.
diff --git a/src/cl/cromer/estructuras/code/listaEnlazadaCircular/buscar b/src/cl/cromer/estructuras/code/listaEnlazadaCircular/buscar
index 1bdddb1..b1ab584 100644
--- a/src/cl/cromer/estructuras/code/listaEnlazadaCircular/buscar
+++ b/src/cl/cromer/estructuras/code/listaEnlazadaCircular/buscar
@@ -10,7 +10,7 @@ public Enlace buscar(int llave) {
}
if (lista.getLlave() == llave) {
- // Devoler el enlace encontrado.
+ // Devoler el listaEnlace encontrado.
return lista;
}
else {
diff --git a/src/cl/cromer/estructuras/code/listaEnlazadaCircular/eliminar b/src/cl/cromer/estructuras/code/listaEnlazadaCircular/eliminar
index 6c91edb..fc40927 100644
--- a/src/cl/cromer/estructuras/code/listaEnlazadaCircular/eliminar
+++ b/src/cl/cromer/estructuras/code/listaEnlazadaCircular/eliminar
@@ -2,14 +2,14 @@ public void eliminar(int llave) {
if (primer != null) {
// Crear una lista temporario para trabajar
Enlace lista = this.primer;
- // Guardar el enlace previo
+ // Guardar el listaEnlace previo
Enlace previo = lista;
// Solo busca mientras que i es menor que la cantidad de enlaces
int i = 0;
while (lista.getLlave() != llave && i < elementos) {
// Buscar hasta la llave es encontraddo
if (lista.getSiguente() != null) {
- // Buscar en el sigenute enlace
+ // Buscar en el sigenute listaEnlace
previo = lista;
lista = lista.getSiguente();
}
@@ -23,11 +23,11 @@ public void eliminar(int llave) {
// Se encontró
if (lista == this.lista) {
- // Si es el primer enlace, cambiarlo al siguente enlace
+ // Si es el primer listaEnlace, cambiarlo al siguente listaEnlace
this.lista = this.lista.getSiguente();
}
else {
- // Sino cortar este enlace de la lista
+ // Sino cortar este listaEnlace de la lista
previo.setSiguente(lista.getSiguente());
}
elementos--;
diff --git a/src/cl/cromer/estructuras/code/listaEnlazadaCircular/insertar b/src/cl/cromer/estructuras/code/listaEnlazadaCircular/insertar
index fbb9445..6f79bdf 100644
--- a/src/cl/cromer/estructuras/code/listaEnlazadaCircular/insertar
+++ b/src/cl/cromer/estructuras/code/listaEnlazadaCircular/insertar
@@ -1,10 +1,10 @@
public void insertar(int llave) {
if (buscar(llave) == null) {
- // Crear un enlace nuevo
+ // Crear un listaEnlace nuevo
Enlace nuevo = new Enlace(primer, llave);
if (primer == null) {
- // Si el primer enlace es null, el ul
+ // Si el primer listaEnlace es null, el ul
ultimo = nuevo;
}
diff --git a/src/cl/cromer/estructuras/code/listaEnlazadaDoble/buscar b/src/cl/cromer/estructuras/code/listaEnlazadaDoble/buscar
index 2ea0b8d..c79ca9f 100644
--- a/src/cl/cromer/estructuras/code/listaEnlazadaDoble/buscar
+++ b/src/cl/cromer/estructuras/code/listaEnlazadaDoble/buscar
@@ -5,7 +5,7 @@ public Enlace buscar(int llave) {
while (lista.getLlave() != llave) {
// Buscar hasta la llave es encontraddo
if (lista.getSiguente() != null) {
- // Buscar en el sigenute enlace
+ // Buscar en el sigenute listaEnlace
lista = lista.getSiguente();
}
else {
@@ -13,7 +13,7 @@ public Enlace buscar(int llave) {
return null;
}
}
- // Se encontró, devolver el enlace
+ // Se encontró, devolver el listaEnlace
return lista;
}
else {
diff --git a/src/cl/cromer/estructuras/code/listaEnlazadaDoble/eliminar b/src/cl/cromer/estructuras/code/listaEnlazadaDoble/eliminar
index e8cacd3..aea60b4 100644
--- a/src/cl/cromer/estructuras/code/listaEnlazadaDoble/eliminar
+++ b/src/cl/cromer/estructuras/code/listaEnlazadaDoble/eliminar
@@ -2,12 +2,12 @@ public void eliminar(int llave) {
if (lista != null) {
// Crear una lista temporario para trabajar
Enlace lista = this.lista;
- // Guardar el enlace previo
+ // Guardar el listaEnlace previo
Enlace previo = lista;
while (lista.getLlave() != llave) {
// Buscar hasta la llave es encontraddo
if (lista.getSiguente() != null) {
- // Buscar en el sigenute enlace
+ // Buscar en el sigenute listaEnlace
previo = lista;
lista = lista.getSiguente();
}
@@ -18,14 +18,14 @@ public void eliminar(int llave) {
}
// Se encontró
if (lista == this.lista) {
- // Si es el primer enlace, cambiarlo al siguente enlace
+ // Si es el primer listaEnlace, cambiarlo al siguente listaEnlace
this.lista = this.lista.getSiguente();
if (this.lista.getPrevio() != null) {
this.lista.setPrevio(null);
}
}
else {
- // Sino cortar este enlace de la lista
+ // Sino cortar este listaEnlace de la lista
previo.setSiguente(lista.getSiguente());
}
}
diff --git a/src/cl/cromer/estructuras/code/listaEnlazadaDoble/insertar b/src/cl/cromer/estructuras/code/listaEnlazadaDoble/insertar
index 58ca44b..e0bc0b5 100644
--- a/src/cl/cromer/estructuras/code/listaEnlazadaDoble/insertar
+++ b/src/cl/cromer/estructuras/code/listaEnlazadaDoble/insertar
@@ -1,12 +1,12 @@
public void insertar(int llave) {
if (buscar(llave) == null) {
- // Crear un enlace nuevo
+ // Crear un listaEnlace nuevo
Enlace nuevo = new Enlace(lista, llave);
if (lista != null) {
// El previo es el nuevo.
lista.setPrevio(nuevo);
}
- // Agregar el enlace a la lista
+ // Agregar el listaEnlace a la lista
lista = nuevo;
}
}
diff --git a/src/cl/cromer/estructuras/code/listaEnlazadaSimple/buscar b/src/cl/cromer/estructuras/code/listaEnlazadaSimple/buscar
index a053358..e5a2564 100644
--- a/src/cl/cromer/estructuras/code/listaEnlazadaSimple/buscar
+++ b/src/cl/cromer/estructuras/code/listaEnlazadaSimple/buscar
@@ -5,7 +5,7 @@ public Enlace buscar(int llave) {
while (lista.getLlave() != llave) {
// Buscar hasta la llave es encontraddo
if (lista.getSiguente() != null) {
- // Buscar en el sigenute enlace
+ // Buscar en el sigenute listaEnlace
lista = lista.getSiguente();
}
else {
@@ -13,7 +13,7 @@ public Enlace buscar(int llave) {
return null;
}
}
- // Se encontró, devolver el enlace
+ // Se encontró, devolver el listaEnlace
return lista;
}
else {
diff --git a/src/cl/cromer/estructuras/code/listaEnlazadaSimple/eliminar b/src/cl/cromer/estructuras/code/listaEnlazadaSimple/eliminar
index aee9fc7..265053e 100644
--- a/src/cl/cromer/estructuras/code/listaEnlazadaSimple/eliminar
+++ b/src/cl/cromer/estructuras/code/listaEnlazadaSimple/eliminar
@@ -2,12 +2,12 @@ public void eliminar(int llave) {
if (lista != null) {
// Crear una lista temporario para trabajar
Enlace lista = this.lista;
- // Guardar el enlace previo
+ // Guardar el listaEnlace previo
Enlace previo = lista;
while (lista.getLlave() != llave) {
// Buscar hasta la llave es encontraddo
if (lista.getSiguente() != null) {
- // Buscar en el sigenute enlace
+ // Buscar en el sigenute listaEnlace
previo = lista;
lista = lista.getSiguente();
}
@@ -18,11 +18,11 @@ public void eliminar(int llave) {
}
// Se encontró
if (lista == this.lista) {
- // Si es el primer enlace, cambiarlo al siguente enlace
+ // Si es el primer listaEnlace, cambiarlo al siguente listaEnlace
this.lista = this.lista.getSiguente();
}
else {
- // Sino cortar este enlace de la lista
+ // Sino cortar este listaEnlace de la lista
previo.setSiguente(lista.getSiguente());
}
}
diff --git a/src/cl/cromer/estructuras/code/listaEnlazadaSimple/insertar b/src/cl/cromer/estructuras/code/listaEnlazadaSimple/insertar
index 2187195..c28cc64 100644
--- a/src/cl/cromer/estructuras/code/listaEnlazadaSimple/insertar
+++ b/src/cl/cromer/estructuras/code/listaEnlazadaSimple/insertar
@@ -1,8 +1,8 @@
public void insertar(int llave) {
if (buscar(llave) == null) {
- // Crear un enlace nuevo
+ // Crear un listaEnlace nuevo
Enlace nuevo = new Enlace(lista, llave);
- // Agregar el enlace a la lista
+ // Agregar el listaEnlace a la lista
lista = nuevo;
}
}
diff --git a/src/cl/cromer/estructuras/fxml/arbol.fxml b/src/cl/cromer/estructuras/fxml/arbol.fxml
new file mode 100644
index 0000000..31a96b9
--- /dev/null
+++ b/src/cl/cromer/estructuras/fxml/arbol.fxml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/cl/cromer/estructuras/fxml/menu.fxml b/src/cl/cromer/estructuras/fxml/menu.fxml
index 966b56a..ca9795f 100644
--- a/src/cl/cromer/estructuras/fxml/menu.fxml
+++ b/src/cl/cromer/estructuras/fxml/menu.fxml
@@ -24,7 +24,7 @@