An implementation of List#equals(Object).
(List<?> thisList, @Nullable Object other)
| 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)}. |
no test coverage detected