List of utility methods to do Iterator
List | listOfIterator(Iterator list Of Iterator List<T> newList = new ArrayList<T>(); while (iterator.hasNext()) { newList.add(iterator.next()); return newList; |
Collection | makeCollection(final Iterator make Collection final List<T> list = new LinkedList<T>(); while (i.hasNext()) { list.add(i.next()); return list; |
Iterator | max(final Iterator don't return more elements than given by max return new Iterator<T>() { int _remaining = max; @Override public boolean hasNext() { return _remaining > 0 && iter.hasNext(); @Override public T next() { ... |
Iterator | mergeIterator(final Iterator merge Iterator final Iterator<T> i1 = iterator1 != null ? iterator1 : new ArrayList<T>(0).iterator(); final Iterator<T> i2 = iterator2 != null ? iterator2 : new ArrayList<T>(0).iterator(); return new Iterator<T>() { private Iterator<T> it = i1; @Override public boolean hasNext() { return i1.hasNext() || i2.hasNext() ? true : false; @Override public T next() { if (this.it.hasNext() == false) { this.it = i2; return this.it.next(); @Override public void remove() { this.it.remove(); }; |
boolean | moveNext(Iterator iterator) move Next if (iterator.hasNext()) { iterator.next(); return true; } else { return false; |
Iterator | multiIterator(Iterator extends X>... iterable) multi Iterator return multiIterator(Arrays.asList(iterable));
|
String[] | multiply(String string, Iterator placeholders, Iterator replacements) multiply String[] result = new String[] { string }; while (placeholders.hasNext()) { result = multiply(result, (String) placeholders.next(), (String[]) replacements.next()); return result; |
String[] | multiply(String string, Iterator placeholders, Iterator replacements) multiply String[] result = new String[] { string }; while (placeholders.hasNext()) { result = multiply(result, (String) placeholders.next(), (String[]) replacements.next()); return result; |
Iterator | multiSetIterator(Iterator extends X>... iterable) multi Set Iterator return multiSetIterator(Arrays.asList(iterable));
|
ArrayList | nextPermutation(Iterator extends Collection next Permutation ArrayList<ArrayList<T>> resultLists = new ArrayList<ArrayList<T>>(); if (it.hasNext()) { Collection<T> next = it.next(); ArrayList<ArrayList<T>> remainingLists = nextPermutation(it); for (T inst : next) { for (ArrayList<T> list : remainingLists) { ArrayList<T> resultList = new ArrayList<T>(); resultLists.add(resultList); ... |