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

List>overlap(List> lists, int before, int after)
Introduces overlap into a series of lists.
if (before < 0) {
    throw new IllegalArgumentException("Value of before cannot be negative");
if (after < 0) {
    throw new IllegalArgumentException("Value of after cannot be negative");
ListIterator<List<T>> iter = lists.listIterator();
List<List<T>> result = new ArrayList<List<T>>();
...
String[]parsePath(String sPath)
Parses the XPath expression in a string array containing the XPath elements.
if (sPath.indexOf("//") >= 0) {
    throw new IllegalArgumentException("Destination path cannot have wild-cards.");
List<String> lElemList = new LinkedList<String>(Arrays.asList(sPath.split("/")));
for (ListIterator<String> iIter = lElemList.listIterator(); iIter.hasNext();) {
    String sElem = iIter.next();
    if (sElem.equals(".")) {
        throw new IllegalArgumentException("Destination path cannot have wild-cards.");
...
voidpartialSort(List list, int numTop, Comparator c)
partial Sort
Object[] a = list.toArray();
partialSort(a, numTop, (Comparator) c);
ListIterator<T> i = list.listIterator();
for (int j = 0; j < a.length; j++) {
    i.next();
    i.set((T) a[j]);
EpeekNext(ListIterator it)
peek Next
E e = null;
if (it.hasNext()) {
    e = it.next();
    it.previous();
return e;
TpeekNext(ListIterator iterator)
peek Next
T next = iterator.next();
iterator.previous();
return next;
voidprint(final List concatenatables)
print
final ListIterator<?> iterator = concatenatables.listIterator();
System.out.print(" ====  ");
while (iterator.hasNext()) {
    final Object a = iterator.next();
    System.out.print(a);
    if (iterator.hasNext())
        System.out.print(" x ");
System.out.println();
ListremoveCustomFilters(List filters)
remove Custom Filters
List<String> mentions = new ArrayList<String>();
ListIterator<String> filterIterator = filters.listIterator();
while (filterIterator.hasNext()) {
    String[] filterSplit = filterIterator.next().split(":");
    if (filterSplit[1].equals("in") && filterSplit[0].equals("mentions")) {
        mentions.add(filterSplit[2]);
        filterIterator.remove();
return mentions;
ListremoveDuplicates(List list)
Keeps and returns the original list.
HashSet<T> set = new HashSet<T>(list.size());
ListIterator<T> i = list.listIterator();
while (i.hasNext()) {
    T cur = i.next();
    if (set.contains(cur)) {
        i.remove();
    } else {
        set.add(cur);
...
voidremoveStartsWith(String prefix, List lines)
remove Starts With
ListIterator<String> it = lines.listIterator();
while (it.hasNext()) {
    String line = it.next();
    if (line.startsWith(prefix)) {
        it.remove();
ListIteratorreset(ListIterator iterator)
reset
while (iterator.hasPrevious()) {
    iterator.previous();
return iterator;