fork download
  1. import scala.collection.mutable._
  2.  
  3. object Main extends App {
  4. def HashMapOrdering = new Ordering[HashMap[Int,Int]] {
  5.  
  6. def compare(a : HashMap[Int,Int], b : HashMap[Int,Int]) = b.valuesIterator.next().compare(a.valuesIterator.next())
  7.  
  8. }
  9.  
  10.  
  11.  
  12. var seeds = PriorityQueue[HashMap[Int, Int]]()(HashMapOrdering)
  13. seeds.enqueue(HashMap(4 -> 4), HashMap(234 -> 5), HashMap(78 -> 6), HashMap(89 -> 1))
  14.  
  15.  
  16.  
  17. seeds.find(x => x.get(89) == Some(1)) match {
  18.  
  19. case Some(hashMap: HashMap[Int, Int]) => hashMap.remove(77); hashMap.put(77,32)
  20. case None => println("Not found")
  21.  
  22. }
  23.  
  24.  
  25. }
Success #stdin #stdout 0.43s 322176KB
stdin
Standard input is empty
stdout
Standard output is empty