List of utility methods to do ListIterator Usage
LinkedList | getAll_SequentialAccess(List Takes all values specified by the given idxs (which must be in ascending order) from values through the use of a ListIterator. LinkedList<V> taken = new LinkedList<V>(); ListIterator<V> valueIter = values.listIterator(); int valuesIdx = -1; V value = null; int lastIdx = -1; for (int idx : idxs) { assert idx >= lastIdx; lastIdx = idx; ... |
LinkedList> | getCamelNameSegments(String camelName) Returns the list of segments used in a camel style name. if (camelName == null || camelName.length() == 0) { return null; @SuppressWarnings("rawtypes") LinkedList segmentList = new LinkedList(); String segment = new String(); segment += camelName.charAt(0); boolean wasDigit = false; ... |
E | getCurrentElement(ListIterator get Current Element listIterator.previous();
return listIterator.next();
|
E | getLastNonNull(List Returns the last non-null element in the given list; or, if there is no non-null element, it returns null. if (l == null) { return null; ListIterator<E> i = l.listIterator(l.size()); while (i.hasPrevious()) { E e = i.previous(); if (e != null) { return e; ... |
void | goToFirst(ListIterator Move the iterator to the first element. while (iterator.hasPrevious()) {
iterator.previous();
|
void | gotoIndex(ListIterator> iterator, int index) goto Index int steps = index - iterator.nextIndex(); if (steps < 0) { steps = 0 - steps; for (int i = 0; i < steps; i++) { iterator.previous(); } else { for (int i = 0; i < steps; i++) { ... |
Object | incrementalComponentWiseAverageArbitraryDepth(Object average, int n, Object newItems) A more general version of incrementalComputationOfComponentWiseAverage(List, int, List) that operates on lists of lists of arbitrary depth, including depth 0, that is, on Number s. if (average instanceof Number) { return (((Number) average).doubleValue() * n + ((Number) newItems).doubleValue()) / (n + 1); ListIterator averageIterator = ((List<Number>) average).listIterator(); ListIterator newItemsIt = ((List) newItems).listIterator(); while (averageIterator.hasNext()) { Object averageElement = averageIterator.next(); Object newItemsElement = newItemsIt.next(); ... |
int | indexOf(List Returns the index of object in list or -1 if the list does not contain the object.
for (ListIterator<E> it = list.listIterator(); it.hasNext();) { if (it.next().equals(object)) { return it.previousIndex(); return -1; |
void | insertBefore(List insert Before if (list != null) { ListIterator<E> iIterator = list.listIterator(); for (E newElement : elements) { iIterator.add(newElement); |
void | intern(ListIterator intern while (in.hasNext()) {
in.set(in.next().intern());
|