@Test public void testOpenBitSetTest() { OpenBitSet bitSet = new OpenBitSet(1000); bitSet.set(0); bitSet.set(100); Assert.assertTrue(bitSet.get(0)); Assert.assertTrue(bitSet.get(100)); Assert.assertFalse(bitSet.get(1)); bitSet.clear(0); Assert.assertFalse(bitSet.get(0)); Assert.assertEquals(bitSet.capacity(), 1024); Assert.assertEquals(bitSet.size(), 1024); Assert.assertEquals(bitSet.length(), 1024); Assert.assertEquals(bitSet.isEmpty(), false); Assert.assertEquals(bitSet.cardinality(), 1); OpenBitSet bitSet2 = new OpenBitSet(1000); bitSet2.set(100); bitSet2.set(1); bitSet2.and(bitSet); Assert.assertTrue(bitSet2.get(100)); Assert.assertFalse(bitSet2.get(1)); bitSet2.intersect(bitSet); Assert.assertTrue(bitSet2.get(100)); OpenBitSet bitSet3 = new OpenBitSet(1000); bitSet3.set(100); Assert.assertTrue(bitSet2.equals(bitSet3)); bitSet3.set(101); bitSet3.set(102); bitSet3.set(103); bitSet3.clear(100, 104); Assert.assertFalse(bitSet3.get(100)); Assert.assertFalse(bitSet3.get(101)); Assert.assertFalse(bitSet3.get(102)); Assert.assertFalse(bitSet3.get(103)); }
public OpenBitSet(long numBits) { wlen = (int) bits2words(numBits); int lastPageSize = wlen % PAGE_SIZE; int fullPageCount = wlen / PAGE_SIZE; pageCount = fullPageCount + (lastPageSize == 0 ? 0 : 1); bits = new long[pageCount][]; for (int i = 0; i < fullPageCount; ++i) { bits[i] = new long[PAGE_SIZE]; } if (lastPageSize != 0) { bits[bits.length - 1] = new long[lastPageSize]; } }
OpenBitSet implements IBitSet { public OpenBitSet(long numBits) { wlen = (int) bits2words(numBits); int lastPageSize = wlen % PAGE_SIZE; int fullPageCount = wlen / PAGE_SIZE; pageCount = fullPageCount + (lastPageSize == 0 ? 0 : 1); bits = new long[pageCount][]; for (int i = 0; i < fullPageCount; ++i) { bits[i] = new long[PAGE_SIZE]; } if (lastPageSize != 0) { bits[bits.length - 1] = new long[lastPageSize]; } } }
OpenBitSet implements IBitSet { public OpenBitSet(long numBits) { wlen = (int) bits2words(numBits); int lastPageSize = wlen % PAGE_SIZE; int fullPageCount = wlen / PAGE_SIZE; pageCount = fullPageCount + (lastPageSize == 0 ? 0 : 1); bits = new long[pageCount][]; for (int i = 0; i < fullPageCount; ++i) { bits[i] = new long[PAGE_SIZE]; } if (lastPageSize != 0) { bits[bits.length - 1] = new long[lastPageSize]; } } OpenBitSet(long numBits);  OpenBitSet(); }
OpenBitSet implements IBitSet { public OpenBitSet(long numBits) { wlen = (int) bits2words(numBits); int lastPageSize = wlen % PAGE_SIZE; int fullPageCount = wlen / PAGE_SIZE; pageCount = fullPageCount + (lastPageSize == 0 ? 0 : 1); bits = new long[pageCount][]; for (int i = 0; i < fullPageCount; ++i) { bits[i] = new long[PAGE_SIZE]; } if (lastPageSize != 0) { bits[bits.length - 1] = new long[lastPageSize]; } } OpenBitSet(long numBits);  OpenBitSet(); int getPageSize(); int getPageCount(); long[] getPage(int pageIdx); long capacity(); long size(); long length(); boolean isEmpty(); int getNumWords(); boolean get(int index); boolean get(long index); void set(long index); void set(int index); void clear(int index); void clear(long index); void clear(int startIndex, int endIndex); void clear(long startIndex, long endIndex); long cardinality(); void intersect(OpenBitSet other); void and(OpenBitSet other); void trimTrailingZeros(); static long bits2words(long numBits); @Override boolean equals(Object o); @Override int hashCode(); void close(); void serialize(DataOutput out); void clear(); static OpenBitSet deserialize(DataInput in); }
OpenBitSet implements IBitSet { public OpenBitSet(long numBits) { wlen = (int) bits2words(numBits); int lastPageSize = wlen % PAGE_SIZE; int fullPageCount = wlen / PAGE_SIZE; pageCount = fullPageCount + (lastPageSize == 0 ? 0 : 1); bits = new long[pageCount][]; for (int i = 0; i < fullPageCount; ++i) { bits[i] = new long[PAGE_SIZE]; } if (lastPageSize != 0) { bits[bits.length - 1] = new long[lastPageSize]; } } OpenBitSet(long numBits);  OpenBitSet(); int getPageSize(); int getPageCount(); long[] getPage(int pageIdx); long capacity(); long size(); long length(); boolean isEmpty(); int getNumWords(); boolean get(int index); boolean get(long index); void set(long index); void set(int index); void clear(int index); void clear(long index); void clear(int startIndex, int endIndex); void clear(long startIndex, long endIndex); long cardinality(); void intersect(OpenBitSet other); void and(OpenBitSet other); void trimTrailingZeros(); static long bits2words(long numBits); @Override boolean equals(Object o); @Override int hashCode(); void close(); void serialize(DataOutput out); void clear(); static OpenBitSet deserialize(DataInput in);  }