Java Utililty Methods ListIterator Usage

List of utility methods to do ListIterator Usage

Description

The list of methods to do ListIterator Usage are organized into topic(s).

Method

int[]toIntegerArray(List 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;
ListtoLowerCase(List 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;
ListtoLowerCase(List stringList)
to Lower Case
ListIterator<String> iterator = stringList.listIterator();
while (iterator.hasNext()) {
    iterator.set(iterator.next().toLowerCase());
return stringList;
Listtoposort(Iterable items, Comparator partOrder)
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();) {
...
voidtrimTail(List l)
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();
IteratorvalueOf(E... elements)
Returns an Iterator instance for the given elements
return Arrays.asList(elements).iterator();
StringwalkTo(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();
...