List of utility methods to do Iterator
List | convertToList(Iterator convert To List List<Double> list = new ArrayList<Double>(); while (iter.hasNext()) list.add(iter.next()); return list; |
Iterator | copy(Iterator copy List<T> list = toList(iterator);
return list.iterator();
|
List | copyIterator(Iterable copy Iterator Iterator<T> iterator = iterable.iterator(); List<T> copy = new ArrayList<T>(); while (iterator.hasNext()) copy.add(iterator.next()); return copy; |
List | copyIterator(Iterator Iterator to List List<T> copy = new ArrayList<T>(); while (iter.hasNext()) copy.add(iter.next()); return copy; |
List | copyOf(Iterator extends E> elements) copy Of if (elements == null) { return null; if (!elements.hasNext()) { return Collections.emptyList(); List<E> list = new ArrayList<>(); while (elements.hasNext()) { ... |
Map | count(Iterator count Map<THING, Integer> countedThings = new HashMap<>(); while (thingsToCount.hasNext()) { THING thing = thingsToCount.next(); if (countedThings.containsKey(thing)) { int count = countedThings.get(thing); countedThings.put(thing, count + 1); } else { countedThings.put(thing, 1); ... |
int | countIterator(Iterator> it) count Iterator int x = 0; while (it.hasNext()) { it.next(); x++; return x; |
Map | createMap(Iterator create Map boolean finished = false; Map<String, String> m = new HashMap<String, String>(); while (iter.hasNext() && !finished) { String row = iter.next(); if (row.startsWith("~")) { finished = true; } else { String[] tokens = row.split("\\^"); ... |
Iterator | createPathIterator(String path) Returns an iterator that iterates over the sub nodes of a path. String tPath = path.startsWith("/") ? path.substring(1) : path; if (tPath.length() == 0) tPath = null; final String aPath = tPath; return new Iterator() { int prevIndex = 0; int curIndex = 0; String pathString = aPath; ... |
Iterable | createSkipIterator(Iterable create Skip Iterator List<S> list = createList(); Iterator<S> iterator = source.iterator(); try { while (count-- > 0) if (!moveNext(iterator)) break; while (iterator.hasNext()) list.add(iterator.next()); ... |