Java ListIterator Usage listEquals(List left, List right)

Here you can find the source of listEquals(List left, List right)

Description

list Equals

License

Apache License

Declaration

public static <T> boolean listEquals(List<T> left, List<T> right) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.List;
import java.util.ListIterator;

public class Main {
    public static <T> boolean listEquals(List<T> left, List<T> right) {
        if (left == right)
            return true;

        ListIterator<T> leftIterator = left.listIterator();
        ListIterator<T> rightIterator = right.listIterator();

        while (leftIterator.hasNext() && rightIterator.hasNext()) {
            T leftElement = leftIterator.next();
            T rightElement = rightIterator.next();
            if (!(leftElement == null ? rightElement == null : leftElement.equals(rightElement)))
                return false;
        }/*  w w  w  . j  a v  a 2s  .c  om*/
        return !(leftIterator.hasNext() || rightIterator.hasNext());
    }
}

Related

  1. intern(ListIterator in)
  2. internStringsInList(List list)
  3. isEqual(java.util.List list1, java.util.List list2)
  4. iteratorBinarySearchGet(ListIterator i, int index)
  5. lastIndexOf(List list, T element)
  6. listHasIdentContent(List list_1, List list_2)
  7. listToStringArray(java.util.List list)
  8. makeSortFieldFallbackExpr(List fieldNames)
  9. normalizeVersion(String version, int length)