@Test public void and() { BitmapAssert.equals( new EmptyBitmap(), FasterAggregation.and(new RangeBitmap(0, 2), new RangeBitmap(4, 6))); BitmapAssert.equals( new EmptyBitmap(), FasterAggregation.and(new RangeBitmap(0, 4), new RangeBitmap(4, 6))); BitmapAssert.equals( RangeBitmap.of(2, 5), FasterAggregation.and(new RangeBitmap(0, 5), new RangeBitmap(2, 10))); BitmapAssert.equals( RangeBitmap.of(4, 6), FasterAggregation.and(new RangeBitmap(0, 100), new RangeBitmap(4, 6))); BitmapAssert.equals( RangeBitmap.of(4, 6), FasterAggregation.and(new RangeBitmap(4, 6), new RangeBitmap(4, 6))); BitmapAssert.equals( RangeBitmap.of(0, 2), FasterAggregation.and(new RangeBitmap(0, 2), new RangeBitmap(-100, 6))); BitmapAssert.equals( RangeBitmap.of(5, 9), FasterAggregation.and(new RangeBitmap(0, 9), new RangeBitmap(5, 20))); BitmapAssert.equals( new EmptyBitmap(), FasterAggregation.and(new RangeBitmap(5, 20), new RangeBitmap(0, 5))); BitmapAssert.equals( new EmptyBitmap(), FasterAggregation.and(new RangeBitmap(100, 101), new RangeBitmap(-100, 0))); }
public static ImmutableBitMap and(RangeBitmap b1, RangeBitmap b2) { if (b1.end < b2.start || b2.end < b1.start) { return new EmptyBitmap(); } int start = Math.max(b1.start, b2.start); int end = Math.min(b1.end, b2.end); return RangeBitmap.of(start, end); }
FasterAggregation { public static ImmutableBitMap and(RangeBitmap b1, RangeBitmap b2) { if (b1.end < b2.start || b2.end < b1.start) { return new EmptyBitmap(); } int start = Math.max(b1.start, b2.start); int end = Math.min(b1.end, b2.end); return RangeBitmap.of(start, end); } }
FasterAggregation { public static ImmutableBitMap and(RangeBitmap b1, RangeBitmap b2) { if (b1.end < b2.start || b2.end < b1.start) { return new EmptyBitmap(); } int start = Math.max(b1.start, b2.start); int end = Math.min(b1.end, b2.end); return RangeBitmap.of(start, end); }  }
FasterAggregation { public static ImmutableBitMap and(RangeBitmap b1, RangeBitmap b2) { if (b1.end < b2.start || b2.end < b1.start) { return new EmptyBitmap(); } int start = Math.max(b1.start, b2.start); int end = Math.min(b1.end, b2.end); return RangeBitmap.of(start, end); }  static ImmutableBitMap or(List<ImmutableBitMap> bitmaps); static ImmutableBitMap compose(List<ImmutableBitMap> bitmaps, final int[] offsets); static ImmutableBitMap or(RangeBitmap b1, RangeBitmap b2); static ImmutableBitMap and(RangeBitmap b1, RangeBitmap b2); static ImmutableBitMap andNot(RangeBitmap b1, RangeBitmap b2); }
FasterAggregation { public static ImmutableBitMap and(RangeBitmap b1, RangeBitmap b2) { if (b1.end < b2.start || b2.end < b1.start) { return new EmptyBitmap(); } int start = Math.max(b1.start, b2.start); int end = Math.min(b1.end, b2.end); return RangeBitmap.of(start, end); }  static ImmutableBitMap or(List<ImmutableBitMap> bitmaps); static ImmutableBitMap compose(List<ImmutableBitMap> bitmaps, final int[] offsets); static ImmutableBitMap or(RangeBitmap b1, RangeBitmap b2); static ImmutableBitMap and(RangeBitmap b1, RangeBitmap b2); static ImmutableBitMap andNot(RangeBitmap b1, RangeBitmap b2);  }