@Test public void testLength() { Mask mask; mask = new Mask(); for (int i = 0, n = 128; i < n; i++) { assertEquals(i, mask.length()); mask.set(i); assertEquals(i + 1, mask.length()); } mask = new Mask(); mask.set(4); assertEquals(5, mask.length()); mask.set(63); assertEquals(64, mask.length()); mask.set(64); assertEquals(65, mask.length()); }
public int length() { final long[] words = this.words; for (int i = words.length - 1; i >= 0; i--) { if (words[i] != 0L) { return (i << 6) + (64 - Long.numberOfLeadingZeros(words[i])); } } return 0; }
Mask { public int length() { final long[] words = this.words; for (int i = words.length - 1; i >= 0; i--) { if (words[i] != 0L) { return (i << 6) + (64 - Long.numberOfLeadingZeros(words[i])); } } return 0; } }
Mask { public int length() { final long[] words = this.words; for (int i = words.length - 1; i >= 0; i--) { if (words[i] != 0L) { return (i << 6) + (64 - Long.numberOfLeadingZeros(words[i])); } } return 0; } Mask(); }
Mask { public int length() { final long[] words = this.words; for (int i = words.length - 1; i >= 0; i--) { if (words[i] != 0L) { return (i << 6) + (64 - Long.numberOfLeadingZeros(words[i])); } } return 0; } Mask(); Mask copyFrom(Mask other); Mask copyFrom(long[] otherWords); void clear(); void or(Mask other); void xor(Mask other); void and(Mask other); void andNot(Mask other); void set(int index); void set(int index, boolean value); void clear(int index); boolean get(int index); int nextSetBit(int index); int nextClearBit(int index); boolean isSupersetOf(Mask other); boolean isSubsetOf(Mask other); boolean intersects(Mask other); int cardinality(); int length(); int[] getIndices(); int getIndices(IntBag out, int offset); long getWord(int index); void setWord(int index, long word); int getWordCount(); long[] getWords(); boolean isEmpty(); @Override String toString(); @Override boolean equals(Object obj); @Override int hashCode(); }
Mask { public int length() { final long[] words = this.words; for (int i = words.length - 1; i >= 0; i--) { if (words[i] != 0L) { return (i << 6) + (64 - Long.numberOfLeadingZeros(words[i])); } } return 0; } Mask(); Mask copyFrom(Mask other); Mask copyFrom(long[] otherWords); void clear(); void or(Mask other); void xor(Mask other); void and(Mask other); void andNot(Mask other); void set(int index); void set(int index, boolean value); void clear(int index); boolean get(int index); int nextSetBit(int index); int nextClearBit(int index); boolean isSupersetOf(Mask other); boolean isSubsetOf(Mask other); boolean intersects(Mask other); int cardinality(); int length(); int[] getIndices(); int getIndices(IntBag out, int offset); long getWord(int index); void setWord(int index, long word); int getWordCount(); long[] getWords(); boolean isEmpty(); @Override String toString(); @Override boolean equals(Object obj); @Override int hashCode();  }