IntegerUnion implements NumberUnion<Integer> { @Override public boolean contains(Object o) { Integer value = (Integer)o; int index = Collections.binarySearch(intervals,value ); if(index>=0) { return true; } else { index = -index - 1; return index % 2 != 0; } } IntegerUnion(int value);  IntegerUnion(int valueBegin, int valueEnd);  IntegerUnion();  IntegerUnion(int[] externalArray);  IntegerUnion(IntegerUnion externalSet);  IntegerUnion(Collection<Integer> externalCollection);  IntegerUnion(Iterator<Integer> valueIterator); @Override boolean equals(Object obj); @Override int hashCode(); @Override boolean isEmpty(); @Override String toString(); @Override boolean remove(Object o); @Override boolean add(Integer value); @Override Iterator<Integer> iterator(); List<Integer> getValueRanges(); @Override Comparator<? super Integer> comparator(); @Override SortedSet<Integer> subSet(Integer e, Integer e1); @Override SortedSet<Integer> headSet(Integer e); @Override SortedSet<Integer> tailSet(Integer e); @Override Integer first(); @Override Integer last(); @Override int size(); @Override boolean contains(Object o); @Override Object[] toArray(); @Override T[] toArray(T[] ts); @Override boolean containsAll(Collection<?> clctn); @Override boolean addAll(Collection<? extends Integer> clctn); @Override boolean retainAll(Collection<?> clctn); @Override boolean removeAll(Collection<?> clctn); @Override void clear(); ListIterator<Integer> listIterator(); ListIterator<Integer> listIterator(int from);  }
@Test public void testContains() { IntegerUnion mergeTool = new IntegerUnion(0, 50); mergeTool.remove(25); mergeTool.remove(26); mergeTool.remove(27); Assert.assertFalse(mergeTool.contains(26)); Assert.assertFalse(mergeTool.contains(25)); Assert.assertFalse(mergeTool.contains(27)); Assert.assertTrue(mergeTool.contains(24)); Assert.assertTrue(mergeTool.contains(28)); Assert.assertTrue(mergeTool.contains(0)); Assert.assertTrue(mergeTool.contains(50)); }