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

voidretainAll(final List list, final Collection indices)
retain All
final ListIterator<?> it = list.listIterator();
while (it.hasNext()) {
    final int index = it.nextIndex();
    it.next();
    if (indices.contains(index)) {
    } else {
        it.remove();
voidrewindIterator(@SuppressWarnings("rawtypes") ListIterator it, int n)
rewind Iterator
for (int i = 0; i < n; i++) {
    it.previous();
Listsort(List aList)
Sort List argument - natural order
List results = null;
if (aList != null) {
    results = new ArrayList();
    Object[] array = aList.toArray();
    Arrays.sort(array);
    List list = Arrays.asList(array);
    ListIterator listIterator = list.listIterator();
    while (listIterator.hasNext()) {
...
ListstringCrossJoin(List> candidates)
string Cross Join
assert candidates != null;
assert candidates.isEmpty() == false;
List<String> results = new ArrayList<>();
Iterator<Set<String>> iter = candidates.iterator();
assert iter.hasNext();
results.addAll(iter.next());
while (iter.hasNext()) {
    Set<String> next = iter.next();
...
ListstringToList(String commas)
Splits a string with commas in it into a string List.
List<String> list = new ArrayList<String>();
ListIterator<String> iterator = Arrays.asList(commas.split("\\s*,\\s*")).listIterator();
if (iterator != null) {
    while (iterator.hasNext()) {
        list.add(iterator.next());
} else
    list = Arrays.asList(commas);
...
ListstripQuotes(List input)
strip Quotes
input = new ArrayList<>(input);
ListIterator<String> iterator = input.listIterator();
while (iterator.hasNext()) {
    String value = iterator.next();
    if (!(value.length() >= 3)) {
        continue;
    if (value.charAt(0) == '"' && value.charAt(value.length() - 1) == '"') {
...
double[]toArray(List a)
to Array
double[] result = new double[a.size()];
for (int i = 0; i < a.size(); i++) {
    result[i] = a.get(i);
return result;
ObjecttoCFML(Object obj)
to CFML
if (obj instanceof Map)
    return toCFML((Map) obj);
if (obj instanceof List)
    return toCFML((List) obj);
return obj;
char[][]toCharArrays(List strings)
to Char Arrays
char[][] charArrays = new char[strings.size()][];
for (ListIterator<String> it = strings.listIterator(); it.hasNext();) {
    int index = it.nextIndex();
    charArrays[index] = it.next().toCharArray();
return charArrays;
inttoInt(final List digits, final int base)
to Int
int pos = 1;
int retVal = 0;
for (ListIterator<Integer> it = digits.listIterator(digits.size()); it.hasPrevious();) {
    retVal += it.previous() * pos;
    pos = pos * base;
return retVal;