add method
dynamic
add(
- dynamic value,
- dynamic cost
Add a new item to the queue and ensure the highest priority element is at the front of the queue.
Implementation
add(value, cost) {
var item = {"value": value, "cost": cost};
queue.add(item);
queue.sort((a, b) {
return a["cost"] - b["cost"];
});
}