Pow2LengthBitSetRange { public boolean encloses(Pow2LengthBitSetRange other) { final boolean result; if (level > other.level) { start.xor(other.start); result = level == start.size() || start.nextSetBit(level) == -1; start.xor(other.start); } else if (level == other.level) { result = start.equals(other.start); } else { result = false; } return result; } Pow2LengthBitSetRange(BitVector start, int level); private  Pow2LengthBitSetRange(BitVector start, int level, int anyInt); BitVector getStart(); int getLevel(); static int levelSum(List<Pow2LengthBitSetRange> pow2LengthOrthotope); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); @Override Pow2LengthBitSetRange clone(); boolean encloses(Pow2LengthBitSetRange other);  }
@Test public void encloses() { final int n = 20; for (int i = 0; i < n; ++i) { for (int iLevel = 0; iLevel < n; ++iLevel) { BitVector iShifted = TestUtils.createBitVector(i << iLevel, n + 32); Pow2LengthBitSetRange iRange = new Pow2LengthBitSetRange(iShifted.clone(), iLevel); for (int j = 0; j < n; ++j) { for (int jLevel = 0; jLevel < n; ++jLevel) { BitVector jShifted = TestUtils.createBitVector(j << jLevel, n + 32); Pow2LengthBitSetRange jRange = new Pow2LengthBitSetRange(jShifted.clone(), jLevel); boolean expected = LongRangeHome.INSTANCE.toRange(iRange).getStart() <= LongRangeHome.INSTANCE.toRange(jRange).getStart() && LongRangeHome.INSTANCE.toRange(iRange).getEnd() >= LongRangeHome.INSTANCE.toRange(jRange).getEnd(); Assert.assertEquals(expected, iRange.encloses(jRange)); Assert.assertEquals(iShifted, iRange.getStart()); Assert.assertEquals(jShifted, jRange.getStart()); } } } } }