}
return removed;
}
final boolean lockedRetainAll(Collection<?> c, int origin, int bound) {
final StampedLock lock = this.lock;
boolean removed = false;
if (c != this) {
long stamp = lock.writeLock();
try {
Object[] items;
int i, n;
if ((items = array) != null && (n = count) > 0 &&
n < items.length && (i = origin) >= 0) {
int fence = bound < 0 || bound > n ? n : bound;
while (i < fence) {
if (c.contains(items[i]))
++i;
else {
--fence;
int mv = --n - i;
if (mv > 0)
System.arraycopy(items, i + 1, items, i, mv);
}
}
if (count != n) {
count = n;
removed = true;
}
}
} finally {
lock.unlockWrite(stamp);
}
}
return removed;
}