IntegerUnion implements NumberUnion<Integer> { @Override public Iterator<Integer> iterator() { return listIterator(); } 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 testIterator() { IntegerUnion mergeTool = new IntegerUnion(); Set<Integer> origin = new TreeSet<Integer>(); for (int i = 51; i < 60; i++) { mergeTool.add(i); origin.add(i); } for (int i = 75; i < 80; i++) { mergeTool.add(i); origin.add(i); } for (int i = 65; i < 74; i++) { mergeTool.add(i); origin.add(i); } Iterator<Integer> itMerge = mergeTool.iterator(); Iterator<Integer> itOrigin = origin.iterator(); while (itMerge.hasNext()) { Integer mergeValue = itMerge.next(); Integer originValue = itOrigin.next(); if (!mergeValue.equals(originValue)) { Assert.assertTrue(mergeValue + "!=" + originValue, mergeValue.equals(originValue)); } } Assert.assertTrue(itMerge.hasNext() == itOrigin.hasNext()); }