PanelSelector { public boolean inPanel(long start, long end) { if (regions.isEmpty()) { return false; } R current = current(); while (index > 0 && current.start() > end) { index--; current = current(); } while (index < regions.size() - 1 && current.end() < start) { index++; current = current(); } if (start <= current.end() && end >= current.start()) { return true; } return false; } PanelSelector(final List<R> regions); boolean inPanel(long start, long end);  }
@Test public void testOverlap() { assertTrue(victim.inPanel(995, 995)); assertTrue(victim.inPanel(994, 996)); assertTrue(victim.inPanel(1102, 1102)); assertTrue(victim.inPanel(1000, 1002)); assertTrue(victim.inPanel(996, 1000)); assertFalse(victim.inPanel(1, 994)); assertTrue(victim.inPanel(998, 998)); assertFalse(victim.inPanel(996, 997)); assertTrue(victim.inPanel(994, 1000)); assertFalse(victim.inPanel(2200, 10000)); }