Last active
December 16, 2015 16:49
-
-
Save javierhonduco/27c7eceddffe1465aa5f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void guardarFichaOrdenada(Ficha ficha){ | |
/* | |
Se anade y luego ordena. Tiene ñacañá complejidad | |
que insertarlo si esta ordenado | |
*/ | |
guardarFicha(ficha); | |
array = new Ficha[getSize()]; | |
DNode<Ficha> current = getFirstNode(); | |
for(int ii = 0; current != getTrailer(); current = current.getNextNode()){ | |
array[ii] = getAt(ii); | |
++ii; | |
} | |
// Bubblesort modificado | |
Ficha aux = null; | |
for(int ii=0; ii < array.length; ++ii){ | |
for (int jj = 1; jj < array.length-1; jj++) { | |
if(array[jj-1].getPropietario().getAppellidos().compareTo(array[jj].getPropietario().getAppellidos()) > 0){ | |
aux = array[jj]; | |
array[jj] = array[jj-1]; | |
array[jj] = aux; | |
} | |
} | |
} | |
// Añadir a la lista | |
for(int ii=array.length; ii != 0; ++ii){ | |
addLast(array[ii]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment