Last active
September 14, 2016 04:15
-
-
Save alvareztech/e40fade88aefd8a6bcc4b77723f7f20c to your computer and use it in GitHub Desktop.
Sugerencia solución
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
// SUGERENCIA DE SOLUCIÓN | |
Queue<Vehiculo> colaVehiculos = new LinkedList<Vehiculo>(); | |
Queue<Soat> colaPrioridadSoats = new PriorityQueue<Soat>(); // Clase Soat debe ser comparable | |
Queue<Soat> tempColaPrioridadSoats = new PriorityQueue<Soat>(); | |
// adicionar datos a las colas (no a la temporal) | |
while (!colaPrioridadSoats.isEmpty()) { | |
Soat s = colaPrioridadSoats.remove(); | |
int n = colaVehiculos.size(); | |
for (int i = 0; i < n; i++) { | |
Vehiculo v = colaVehiculos.remove(); | |
v.setSoat(s); | |
colaVehiculos.add(v); | |
} | |
tempColaPrioridadSoats.add(s); | |
} | |
while (!tempColaPrioridadSoats.isEmpty()) { | |
Soat s = tempColaPrioridadSoats.remove(); | |
colaPrioridadSoats.add(s); | |
} | |
// mostrar la cola de vehiculos con toda la información | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment