Skip to content

Instantly share code, notes, and snippets.

@alvareztech
Created September 14, 2016 03:59
Show Gist options
  • Save alvareztech/444730c853d669fa9f2eeae744a15386 to your computer and use it in GitHub Desktop.
Save alvareztech/444730c853d669fa9f2eeae744a15386 to your computer and use it in GitHub Desktop.
Métodos mostrar cola simple y cola de prioridad en Java
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