List of utility methods to do Iterator
Iterator | dump(Iterator dump List<T> list = new ArrayList<T>(); while (it.hasNext()) { list.add(it.next()); System.out.println(list); return list.iterator(); |
boolean | endOfData(Iterator end Of Data return !resultIter.hasNext() || !inputIter.hasNext();
|
boolean | equalsIterator(Iterator> it, Iterator> it2) equals Iterator if (it == it2) return true; while (it.hasNext() && it2.hasNext()) { if (!it.next().equals(it2.next())) return false; return !it.hasNext() && !it2.hasNext(); |
S | fill(final Iterator fill while (iterator.hasNext()) { collection.add(iterator.next()); return collection; |
void | fillArray(Iterator ii, Object[] fillMe, boolean null_terminate) Fills an array with the contents of an iterator. int i = 0; int len = fillMe.length; while (i < len && ii.hasNext()) fillMe[i++] = ii.next(); if (null_terminate && i < len) fillMe[i] = null; |
void | fillCollection(final Iterator fill Collection while (iterator.hasNext()) {
collection.add(iterator.next());
|
void | fillCollection(final Iterator Drain an iterator into a collection. try { while (true) { collection.add(iterator.next()); } catch (final NoSuchElementException e) { |
T | firstOrDefault(Iterator first Or Default if (!iterator.hasNext()) { return null; return iterator.next(); |
String | fmtSeq(Iterator it, String divider) fmt Seq String resString = new String(); boolean first = true; while (it.hasNext()) { if (first) first = false; else resString += divider; resString += it.next(); ... |
Set | fromIterator(Iterator iterator) Create a set containing the elements of an iterator Set l = set(); while (iterator.hasNext()) { l.add(iterator.next()); return l; |