X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.utils.datastructures%2Fsrc%2Forg%2Fsimantics%2Futils%2Fdatastructures%2FArrayMap.java;h=b9b5415d85ba3b1a779189151ad9b51cf5470fae;hp=7115f29d51bb82db3883a5108d2a7eb973626433;hb=53059ca1a958697cc6235d27628614fbaa944d59;hpb=e87f0965679502de281692c298d66a7ae9507bd8 diff --git a/bundles/org.simantics.utils.datastructures/src/org/simantics/utils/datastructures/ArrayMap.java b/bundles/org.simantics.utils.datastructures/src/org/simantics/utils/datastructures/ArrayMap.java index 7115f29d5..b9b5415d8 100644 --- a/bundles/org.simantics.utils.datastructures/src/org/simantics/utils/datastructures/ArrayMap.java +++ b/bundles/org.simantics.utils.datastructures/src/org/simantics/utils/datastructures/ArrayMap.java @@ -39,8 +39,8 @@ import java.util.Set; */ public class ArrayMap implements Map { - K[] keys; - V[] values; + final K[] keys; + final V[] values; Set> entrySet; Set keySet; Collection valueSet; @@ -292,7 +292,7 @@ public class ArrayMap implements Map { public Map.Entry next() { if (i >= keys.length) throw new NoSuchElementException("no more elements (" + keys.length + " walked)"); - Map.Entry entry = new Entry(i, keys[i], values[i]); + Map.Entry entry = new ArrayMapEntry(i, keys[i], values[i]); ++i; return entry; } @@ -306,63 +306,6 @@ public class ArrayMap implements Map { } - static class Entry implements Map.Entry { - final K key; - V value; - - /** - * Creates new entry. - */ - Entry(int h, K k, V v) { - value = v; - key = k; - } - - @Override - public final K getKey() { - return key; - } - - @Override - public final V getValue() { - return value; - } - - @Override - public final V setValue(V newValue) { - V oldValue = value; - value = newValue; - return oldValue; - } - - @Override - public final boolean equals(Object o) { - if (!(o instanceof Map.Entry)) - return false; - Map.Entry e = (Map.Entry)o; - Object k1 = getKey(); - Object k2 = e.getKey(); - if (k1 == k2 || (k1 != null && k1.equals(k2))) { - Object v1 = getValue(); - Object v2 = e.getValue(); - if (v1 == v2 || (v1 != null && v1.equals(v2))) - return true; - } - return false; - } - - @Override - public final int hashCode() { - return (key==null ? 0 : key.hashCode()) ^ - (value==null ? 0 : value.hashCode()); - } - - @Override - public final String toString() { - return getKey() + "=" + getValue(); - } - } - /** * Returns the hash code value for this map. The hash code of a map is * defined to be the sum of the hash codes of each entry in the map's