745 |
|
final int from, final int end) { |
746 |
|
Objects.requireNonNull(c); |
747 |
|
final Object[] es = elementData; |
748 |
– |
final boolean modified; |
748 |
|
int r; |
749 |
|
// Optimize for initial run of survivors |
750 |
< |
for (r = from; r < end && c.contains(es[r]) == complement; r++) |
751 |
< |
; |
752 |
< |
if (modified = (r < end)) { |
753 |
< |
int w = r++; |
754 |
< |
try { |
755 |
< |
for (Object e; r < end; r++) |
756 |
< |
if (c.contains(e = es[r]) == complement) |
757 |
< |
es[w++] = e; |
758 |
< |
} catch (Throwable ex) { |
759 |
< |
// Preserve behavioral compatibility with AbstractCollection, |
760 |
< |
// even if c.contains() throws. |
761 |
< |
System.arraycopy(es, r, es, w, end - r); |
762 |
< |
w += end - r; |
763 |
< |
throw ex; |
764 |
< |
} finally { |
765 |
< |
modCount += end - w; |
766 |
< |
shiftTailOverGap(es, w, end); |
767 |
< |
} |
750 |
> |
for (r = from;; r++) { |
751 |
> |
if (r == end) |
752 |
> |
return false; |
753 |
> |
if (c.contains(es[r]) != complement) |
754 |
> |
break; |
755 |
> |
} |
756 |
> |
int w = r++; |
757 |
> |
try { |
758 |
> |
for (Object e; r < end; r++) |
759 |
> |
if (c.contains(e = es[r]) == complement) |
760 |
> |
es[w++] = e; |
761 |
> |
} catch (Throwable ex) { |
762 |
> |
// Preserve behavioral compatibility with AbstractCollection, |
763 |
> |
// even if c.contains() throws. |
764 |
> |
System.arraycopy(es, r, es, w, end - r); |
765 |
> |
w += end - r; |
766 |
> |
throw ex; |
767 |
> |
} finally { |
768 |
> |
modCount += end - w; |
769 |
> |
shiftTailOverGap(es, w, end); |
770 |
|
} |
771 |
|
// checkInvariants(); |
772 |
< |
return modified; |
772 |
> |
return true; |
773 |
|
} |
774 |
|
|
775 |
|
/** |