IntegerUnion implements NumberUnion<Integer> { @Override public boolean remove(Object o) { Integer value = (Integer) o; return internalRemove(value); } 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 testRemove() { IntegerUnion mergeTool = new IntegerUnion(0, 50); Assert.assertTrue(mergeTool.remove(0)); check(mergeTool, new Integer[]{1, 50}); Assert.assertTrue(mergeTool.remove(50)); check(mergeTool, new Integer[]{1, 49}); Assert.assertTrue(mergeTool.remove(2)); check(mergeTool, new Integer[]{1, 1, 3, 49}); Assert.assertTrue(mergeTool.remove(1)); check(mergeTool, new Integer[]{3, 49}); Assert.assertTrue(mergeTool.remove(48)); check(mergeTool, new Integer[]{3, 47, 49, 49}); Assert.assertTrue(mergeTool.remove(49)); check(mergeTool, new Integer[]{3, 47}); Assert.assertTrue(mergeTool.remove(44)); check(mergeTool, new Integer[]{3, 43, 45, 47}); Assert.assertTrue(mergeTool.remove(43)); check(mergeTool, new Integer[]{3, 42, 45, 47}); Assert.assertTrue(mergeTool.remove(46)); check(mergeTool, new Integer[]{3, 42, 45, 45, 47, 47}); Assert.assertFalse(mergeTool.remove(46)); Assert.assertTrue(mergeTool.remove(45)); check(mergeTool, new Integer[]{3, 42, 47, 47}); Assert.assertTrue(mergeTool.remove(47)); check(mergeTool, new Integer[]{3, 42}); mergeTool = new IntegerUnion(0); Assert.assertTrue(mergeTool.remove(0)); check(mergeTool, new Integer[]{}); Assert.assertFalse(mergeTool.remove(0)); mergeTool = new IntegerUnion(); mergeTool.add(51); mergeTool.add(49); mergeTool.remove(48); mergeTool.remove(49); mergeTool.remove(50); check(mergeTool, new Integer[]{51,51}); mergeTool = new IntegerUnion(); HashSet<Integer> set = new HashSet<Integer>(); for (int i = 51; i < 60; i+=3) { Assert.assertTrue(mergeTool.add(i)==set.add(i)); } for (int i = 45; i < 50; i++) { Assert.assertTrue(mergeTool.add(i)==set.add(i)); } for (int i = 45; i < 65; i+=2) { Assert.assertTrue("i="+i,mergeTool.remove(i)==set.remove(i)); } Assert.assertTrue(set.containsAll(mergeTool)); }