fork download
  1. import scala.collection.mutable.PriorityQueue
  2.  
  3. case class Node(var distance: Double, var path: String, var visited: Boolean)
  4. extends Ordered[Node]{
  5. def compare(other: Node) = other.distance.compare(distance);
  6. }
  7.  
  8. object Main extends App {
  9. var x = PriorityQueue[Node]();
  10. x += Node(1.0/0, "cool", true);
  11. x += Node(3.0, "cook", false);
  12. x += Node(7.5, "coos", true);
  13. var y = x dequeue;
  14. y.distance = 4.0;
  15. x += y;
  16. x foreach println;
  17. while (x.nonEmpty) println(x dequeue);
  18. }
Success #stdin #stdout 0.38s 322240KB
stdin
Standard input is empty
stdout
Node(4.0,cook,false)
Node(Infinity,cool,true)
Node(7.5,coos,true)
Node(4.0,cook,false)
Node(7.5,coos,true)
Node(Infinity,cool,true)