List of utility methods to do Iterator
Iterator | singletonIterator(final Object item) singleton Iterator return new Iterator() { private boolean gotItem = false; public boolean hasNext() { return !this.gotItem; public Object next() { if (this.gotItem) { throw new NoSuchElementException(); ... |
Iterator | singletonIterator(final T item) Returns a singleton iterator with a single item. return new Iterator<T>() { private T _item = item; private boolean _hasItem = false; @Override public boolean hasNext() { return !_hasItem; @Override ... |
Iterator | singletonIterator(final T nullableValue) singleton Iterator if (nullableValue == null) { return (Iterator<T>) EMPTY_ITERATOR; return new Iterator<T>() { boolean done; @Override public boolean hasNext() { return !done; ... |
Iterator | singletonIterator(final T t) singleton Iterator return Collections.singletonList(t).iterator();
|
int | size(Iterator iterator) size int count = 0; while (iterator.hasNext()) { iterator.next(); count++; return count; |
void | splice(LinkedList splice list2.remove(v);
assert (iterator.equals(list.iterator()));
list.addFirst(v);
|
Object[] | toArray(final Iterator iterator) to Array final List<Object> out = new ArrayList<Object>(); while (iterator.hasNext()) { out.add(iterator.next()); return out.toArray(); |
void | toCollection(final Iterator to Collection while (iterator.hasNext()) {
c.add(iterator.next());
|
String | toCommaSeparatedString(Iterator extends Object> i) to Comma Separated String StringBuilder sb = new StringBuilder(); for (; i.hasNext();) { sb.append(i.next().toString()); if (i.hasNext() == true) { sb.append(", "); return sb.toString(); ... |
Iterator | toIterator(Collection Get an iterator from a collection, returning null if collection is null if (col == null) return null; else return col.iterator(); |