List of utility methods to do Iterator
Iterator | toIterator(final T[] data) Creates an iterator over the supplied array. if (data == null) { return null; return new Iterator<T>() { public boolean hasNext() { return (_index < data.length); public T next() { ... |
Map | toMap(final Iterator Generics equivalent of commons-collections' IteratorUtils.toMap() final Map<K, V> ret = new HashMap<K, V>(); Map.Entry<K, V> entry; while (iterator.hasNext()) { entry = iterator.next(); ret.put(entry.getKey(), entry.getValue()); return ret; |
Iterator | toObjectIterator(Object[] objects) to Object Iterator return Arrays.asList(objects).iterator();
|
Set | toSet(Iterator extends T> iteration) to Set Set<T> elements = new HashSet<T>(1); while (iteration.hasNext()) { elements.add(iteration.next()); return elements; |
String | toString(Iterator> iterObjects) to String return toString(iterObjects, false);
|
String | toString(Iterator to String Iterable<String> iterable = () -> tokens; return String.join(" ", iterable); |
String[] | toStringArray(Iterator Creates a new array of String objects, containing the elements of a supplied Iterator .
if (null == iterator) { return new String[0]; ArrayList<String> strings = new ArrayList<>(); while (iterator.hasNext()) { strings.add(iterator.next()); String[] string_array = new String[strings.size()]; ... |
Object[] | unwrapIterator(Iterator iter) unwrap Iterator ArrayList<Object> ret = new ArrayList<Object>(); while (iter.hasNext()) { ret.add(iter.next()); return ret.toArray(); |