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

Method equalsImpl

output/java_guava/1.4.18/Lists.java:1030–1053  ·  view source on GitHub ↗

An implementation of List#equals(Object).

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

Source from the content-addressed store, hash-verified

1028
1029
1030 static boolean equalsImpl(List<?> thisList, @Nullable Object other) {
1031 if (other == checkNotNull(thisList)) {
1032 return true;
1033 }
1034 if (!(other instanceof List)) {
1035 return false;
1036 }
1037 List<?> otherList = (List<?>) other;
1038 int size = thisList.size();
1039 if (size != otherList.size()) {
1040 return false;
1041 }
1042 if (thisList instanceof RandomAccess && otherList instanceof RandomAccess) {
1043 // avoid allocation and use the faster loop
1044 for (int i = 0; i < size; i++) {
1045 if (!Objects.equal(thisList.get(i), otherList.get(i))) {
1046 return false;
1047 }
1048 }
1049 return true;
1050 } else {
1051 return Iterators.elementsEqual(thisList.iterator(), otherList.iterator());
1052 }
1053 }
1054
1055 /**
1056 * 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