AscendingBitSetIndexToIndexMultiMap implements IndexToIndexMultiMap { @Override public boolean getBetween( @NotNull final BitSet dest, final int fromInclusive, final int toExclusive) { assert 0 <= fromInclusive && fromInclusive < toExclusive && toExclusive <= keysCount; final ArrayBitSet target = borrowBitSet(dest.getSize()); try { getTo(target, toExclusive); if (fromInclusive != 0) { target.xor(elements, fromInclusive * bitSetSizeInBytes, bitSetSizeInLongs); } return dest.or(target); } finally { release(target); } } private  AscendingBitSetIndexToIndexMultiMap(
            final int keysCount,
            @NotNull
            final Buffer elements,
            final int bitSetSizeInLongs); @NotNull static AscendingBitSetIndexToIndexMultiMap from(
            @NotNull
            final Buffer buf); @Override boolean get(
            @NotNull
            final BitSet dest,
            final int key); @Override boolean getFrom(
            @NotNull
            final BitSet dest,
            final int fromInclusive); @Override boolean getTo(
            @NotNull
            final BitSet dest,
            final int toExclusive); @Override boolean getBetween(
            @NotNull
            final BitSet dest,
            final int fromInclusive,
            final int toExclusive); @Override int getKeysCount(); @Override String toString(); @NotNull @Override Iterator<IntToIntArray> ascending(
            @NotNull
            final BitSet valueFilter); @NotNull @Override Iterator<IntToIntArray> descending(
            @NotNull
            final BitSet valueFilter);  }
@Test public void getBetween() { AscendingBitSetIndexToIndexMultiMap index = build(); final BitSet dest = LongArrayBitSet.zero(DOCS); final BitSet expected = LongArrayBitSet.zero(DOCS); expected.set(4); expected.set(5); expected.set(6); expected.set(7); assertTrue("Destination non-zero", index.getBetween(dest, 2, 4)); dest.xor(expected); assertTrue("Documents (4, 5, 6, 7) are set", dest.cardinality() == 0); }
@Test public void releaseToNullPool() { AscendingBitSetIndexToIndexMultiMap index = build(); final BitSet dest = LongArrayBitSet.zero(DOCS); final BitSet expected = LongArrayBitSet.zero(DOCS); expected.set(4); expected.set(5); expected.set(6); expected.set(7); assertTrue("Destination non-zero", index.getBetween(dest, 2, 4)); dest.xor(expected); assertTrue("Documents (4, 5, 6, 7) are set", dest.cardinality() == 0); }