O'Reilly logo
  • Ovidiu Sofariu thinks this is interesting:

def equalMaps(hm: HashMap[Int,Any], im: IntMap[Any]) = {   im.keys.forall(hm.containsKey) &&   hm.keySet.containsAll(im.keys) &&   im.keys.forall(k => im(k) == hm(k)) }

From

Cover of ScalaCheck: The Definitive Guide

Note

implementation is incorrect. This is better: def equalMaps(hm: util.HashMap[Int, Any], im: IntMap[Any]) = { im.keys.forall(hm.containsKey) && hm.keySet.asScala.forall(im.contains) && im.keys.forall(k => im(k) == hm.get(k)) }