Java ListIterator Usage gotoIndex(ListIterator iterator, int index)

Here you can find the source of gotoIndex(ListIterator iterator, int index)

Description

goto Index

License

Open Source License

Declaration

public static void gotoIndex(ListIterator<?> iterator, int index) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.ListIterator;

public class Main {
    public static void gotoIndex(ListIterator<?> iterator, int index) {
        int steps = index - iterator.nextIndex();
        if (steps < 0) {
            steps = 0 - steps;//from   w w w  .  ja v a  2s  .  c om

            for (int i = 0; i < steps; i++) {
                iterator.previous();
            }
        } else {
            for (int i = 0; i < steps; i++) {
                iterator.next();
            }
        }
    }
}

Related

  1. getAll_SequentialAccess( List idxs, List values)
  2. getCamelNameSegments(String camelName)
  3. getCurrentElement(ListIterator listIterator)
  4. getLastNonNull(List l)
  5. goToFirst(ListIterator iterator)
  6. incrementalComponentWiseAverageArbitraryDepth(Object average, int n, Object newItems)
  7. indexOf(List list, E object)
  8. insertBefore(List list, E... elements)
  9. intern(ListIterator in)