ShortSet implements Serializable { @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } final ShortSet that = (ShortSet) obj; if (that.data.length != data.length) { return false; } if (that.size != size) { return false; } for (int i = 0; i < size; i++) { if (!that.contains(data[i])) { return false; } } return true; } ShortSet(int capacity); void add(short key); void addAll(ShortSet that); void addKnownAbsent(short key); void clear(); boolean contains(short key); void copyDataFrom(ShortSet that); @Override boolean equals(Object obj); short get(int i); @Override int hashCode(); void remove(short key); void removeKnownPresent(int key); int size(); @Override String toString(); String toString(CoordinateSystem coords);  }
@Test public void testEquals() { assertFalse(set.equals(null)); assertFalse(set.equals("a String")); set.add((short)4); set.add((short)5); assertTrue(set.equals(set)); ShortSet other = new ShortSet(CAPACITY); other.add((short)5); other.add((short)7); other.add((short)6); assertTrue(other.equals(other)); assertFalse(set.equals(other)); other.add((short)4); other.remove((short)6); other.remove((short)7); assertTrue(other.equals(set)); assertTrue(set.equals(other)); ShortSet other2 = new ShortSet(12); other2.add((short)4); other2.add((short)5); assertFalse(other2.equals(set)); assertFalse(other2.equals(other)); ShortSet other3 = new ShortSet(CAPACITY); other3.add((short)4); other3.add((short)9); assertFalse(other3.equals(set)); assertFalse(set.equals(other3)); }