List of utility methods to do Iterator from
T | getIndexInIterator(Iterator get Index In Iterator for (int i = 0; iterator.hasNext(); i++) { T current = iterator.next(); if (i == index) { return current; return null; |
Iterable | getIterable(final Iterator Wraps iterator into iterable return new Iterable<T>() { @Override public Iterator<T> iterator() { return i; }; |
Iterator | getIterator(final int[] p, final Object[] data) Answer iterator, which iterates over specified data array according to the specified permutation, that is data[p[0]],..,data[p[data.length-1]]
return new Iterator() { int pos = 0; public boolean hasNext() { return pos < data.length; public Object next() { return data[p[pos++]]; public void remove() { throw new UnsupportedOperationException("Cannot remove from immutable iterator!"); }; |
Iterator | getIterator(final Object o, final Class Cast an object into a typed iterator. final List<T> list = new ArrayList<>(); if (o != null && classElement != null && Iterator.class.isAssignableFrom(o.getClass())) { Iterator<?> mObj = (Iterator<?>) o; while (mObj.hasNext()) { Object obj = mObj.next(); if (obj == null) { list.add(null); } else if (classElement.isAssignableFrom(obj.getClass())) { ... |
Iterator | getIterator(List get Iterator Iterator i = list.iterator();
return i;
|
Iterator | getIterator(T[] array) Construct an iterator from an array. return Arrays.asList(array).iterator();
|
String | getIteratorAsString(Iterator iter, final String separator) Returns a string containing all entries found. StringBuffer buf = new StringBuffer(); boolean isFirst = true; while (iter.hasNext()) { if (isFirst) isFirst = false; else buf.append(separator); buf.append(iter.next()); ... |
String | getIteratorOptionalValue(final Iterator get Iterator Optional Value return stringIterator.hasNext() ? stringIterator.next() : ""; |
T | getLast(Iterator get Last T last = null; while (iterator.hasNext()) { last = iterator.next(); return last; |
List | getList(Iterator Creates a list of all of the items in an iteration. List<String> contents = new ArrayList<String>(); while (iterator.hasNext()) { contents.add(iterator.next()); return contents; |