List of utility methods to do ListIterator Usage
int[] | toIntegerArray(List to Integer Array int[] output = new int[list.size()]; for (ListIterator<Integer> iterator = list.listIterator(); iterator.hasNext();) { int i = iterator.nextIndex(); Object o = iterator.next(); output[i] = (int) o; return output; |
List | toLowerCase(List Turns every element in the given String list into lowercase ListIterator<String> iterator = list.listIterator(); while (iterator.hasNext()) { iterator.set(iterator.next().toLowerCase()); return list; |
List | toLowerCase(List to Lower Case ListIterator<String> iterator = stringList.listIterator(); while (iterator.hasNext()) { iterator.set(iterator.next().toLowerCase()); return stringList; |
List | toposort(Iterable Brute-force topological sort, required because element types are only partially ordered: there is no ordering amongst metamodel types nor amongst unrelated specialization types. List<T> unsorted = new LinkedList<T>(); for (T next : items) { unsorted.add(next); List<T> result = new ArrayList<T>(unsorted.size()); while (!unsorted.isEmpty()) { T min = unsorted.remove(0); for (ListIterator<T> iter = unsorted.listIterator(); iter.hasNext();) { ... |
void | trimTail(List Remove all null elements at the end of the list. final ListIterator<T> it = l.listIterator(l.size()); while (it.hasPrevious()) { if (it.previous() != null) return; it.remove(); |
Iterator | valueOf(E... elements) Returns an Iterator instance for the given elements return Arrays.asList(elements).iterator();
|
String | walkTo(String target, String path, int offset) Go to last occurrence of target in path List<String> pathParts = getPathParts(path); target = target.toLowerCase(); pathBuilder = new StringBuilder(); int locationOfTarget = pathParts.lastIndexOf(target); ListIterator<String> iter = pathParts.listIterator(); while (iter.hasNext()) { String part = iter.next(); int index = iter.nextIndex(); ... |