25 |
|
import java.util.List; |
26 |
|
import java.util.ListIterator; |
27 |
|
import java.util.NoSuchElementException; |
28 |
+ |
import java.util.Objects; |
29 |
|
import java.util.RandomAccess; |
30 |
|
import java.util.Spliterator; |
31 |
|
import java.util.Spliterators; |
156 |
|
} |
157 |
|
|
158 |
|
/** |
158 |
– |
* Tests for equality, coping with nulls. |
159 |
– |
*/ |
160 |
– |
private static boolean eq(Object o1, Object o2) { |
161 |
– |
return (o1 == null) ? o2 == null : o1.equals(o2); |
162 |
– |
} |
163 |
– |
|
164 |
– |
/** |
159 |
|
* static version of indexOf, to allow repeated calls without |
160 |
|
* needing to re-acquire array each time. |
161 |
|
* @param o element to search for |
501 |
|
if (snapshot != current) findIndex: { |
502 |
|
int prefix = Math.min(index, len); |
503 |
|
for (int i = 0; i < prefix; i++) { |
504 |
< |
if (current[i] != snapshot[i] && eq(o, current[i])) { |
504 |
> |
if (current[i] != snapshot[i] |
505 |
> |
&& Objects.equals(o, current[i])) { |
506 |
|
index = i; |
507 |
|
break findIndex; |
508 |
|
} |
582 |
|
// Optimize for lost race to another addXXX operation |
583 |
|
int common = Math.min(snapshot.length, len); |
584 |
|
for (int i = 0; i < common; i++) |
585 |
< |
if (current[i] != snapshot[i] && eq(e, current[i])) |
585 |
> |
if (current[i] != snapshot[i] |
586 |
> |
&& Objects.equals(e, current[i])) |
587 |
|
return false; |
588 |
|
if (indexOf(e, current, common, len) >= 0) |
589 |
|
return false; |
949 |
|
List<?> list = (List<?>)o; |
950 |
|
Iterator<?> it = list.iterator(); |
951 |
|
Object[] elements = getArray(); |
952 |
< |
int len = elements.length; |
953 |
< |
for (int i = 0; i < len; ++i) |
958 |
< |
if (!it.hasNext() || !eq(elements[i], it.next())) |
952 |
> |
for (int i = 0, len = elements.length; i < len; i++) |
953 |
> |
if (!it.hasNext() || !Objects.equals(elements[i], it.next())) |
954 |
|
return false; |
955 |
|
if (it.hasNext()) |
956 |
|
return false; |