Created
September 14, 2016 03:59
-
-
Save alvareztech/444730c853d669fa9f2eeae744a15386 to your computer and use it in GitHub Desktop.
Métodos mostrar cola simple y cola de prioridad en Java
This file contains hidden or 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 static void mostrarColaPrioridad(Queue<Persona> colaPrioridad) { | |
System.out.println("mostrar"); | |
Queue<Persona> temp = new PriorityQueue<Persona>(); | |
while (!colaPrioridad.isEmpty()) { | |
Persona p = colaPrioridad.remove(); | |
System.out.println("Nombre: " + p.getNombre()); | |
temp.add(p); | |
} | |
while (!temp.isEmpty()) { | |
Persona p = temp.remove(); | |
colaPrioridad.add(p); | |
} | |
} | |
public static void mostrarColaSimple(Queue<Persona> colaSimple) { | |
int n = colaSimple.size(); | |
for (int i = 0; i < n; i++) { | |
Persona p = colaSimple.remove(); | |
System.out.println("Nombre: " + p.getNombre()); | |
colaSimple.add(p); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment