MCPcopy Create free account
hub / github.com/antlr/codebuff / equalsImpl

Method equalsImpl

corpus/java/training/guava/collect/Lists.java:997–1020  ·  view source on GitHub ↗

An implementation of List#equals(Object).

(List<?> thisList, @Nullable Object other)

Source from the content-addressed store, hash-verified

995 * An implementation of {@link List#equals(Object)}.
996 */
997 static boolean equalsImpl(List<?> thisList, @Nullable Object other) {
998 if (other == checkNotNull(thisList)) {
999 return true;
1000 }
1001 if (!(other instanceof List)) {
1002 return false;
1003 }
1004 List<?> otherList = (List<?>) other;
1005 int size = thisList.size();
1006 if (size != otherList.size()) {
1007 return false;
1008 }
1009 if (thisList instanceof RandomAccess && otherList instanceof RandomAccess) {
1010 // avoid allocation and use the faster loop
1011 for (int i = 0; i < size; i++) {
1012 if (!Objects.equal(thisList.get(i), otherList.get(i))) {
1013 return false;
1014 }
1015 }
1016 return true;
1017 } else {
1018 return Iterators.elementsEqual(thisList.iterator(), otherList.iterator());
1019 }
1020 }
1021
1022 /**
1023 * An implementation of {@link List#addAll(int, Collection)}.

Callers 2

standardEqualsMethod · 0.95
equalsMethod · 0.95

Calls 6

equalMethod · 0.95
elementsEqualMethod · 0.95
sizeMethod · 0.65
getMethod · 0.65
iteratorMethod · 0.65
checkNotNullMethod · 0.45

Tested by

no test coverage detected