public static int mapHash(IPersistentMap m) { int hash = 0; for (ISeq s = m.seq(); s != null; s = s.next()) { Map.Entry e = (Map.Entry) s.first(); hash += (e.getKey() == null ? 0 : e.getKey().hashCode()) ^ (e.getValue() == null ? 0 : e.getValue().hashCode()); } return hash; }
public static boolean mapEquals(IPersistentMap m1, Object obj) { if (m1 == obj) return true; if (!(obj instanceof Map)) return false; Map m = (Map) obj; if (m.size() != m1.count()) return false; for (ISeq s = m1.seq(); s != null; s = s.next()) { Map.Entry e = (Map.Entry) s.first(); boolean found = m.containsKey(e.getKey()); if (!found || !Util.equals(e.getValue(), m.get(e.getKey()))) return false; } return true; }