bitmap4 implements XdrAble, Iterable<Integer> { @Override public int hashCode() { int hash = 1; if (value != null) { int n; for(n = value.length; n > 0 && value[n-1] == 0; n--) ; for (int i = 0; i < n; i++) { hash = 31 * hash + value[i]; } } return hash; } bitmap4();  bitmap4(int [] value);  bitmap4(XdrDecodingStream xdr); void xdrEncode(XdrEncodingStream xdr); void xdrDecode(XdrDecodingStream xdr); static bitmap4 of(int ... values); void set(int bit); boolean isSet(int bit); boolean isEmpty(); @Override Iterator<Integer> iterator(); @Override int hashCode(); @Override boolean equals(Object obj); public int[] value; }
@Test public void testSameBitsDifferentSize() { bitmap4 b1 = new bitmap4 ( new int[] {8, 0, 5, 0, 0}); bitmap4 b2 = new bitmap4 ( new int[] {8, 0, 5}); assertEquals("arrays size must be ignored", b1, b2); assertEquals("arrays size must be ignored", b1.hashCode(), b2.hashCode()); }
@Test public void testSameSizeDifferentBits() { bitmap4 b1 = new bitmap4(new int[]{0, 1}); bitmap4 b2 = new bitmap4(new int[]{1}); assertNotEquals("different bits not respected", b1, b2); assertNotEquals("different bits not respected", b1.hashCode(), b2.hashCode()); }