Simplify two remove-if loops (#77)
These are semantically identical easier to read.
This commit is contained in:
parent
8cbb4fd865
commit
07b82f6a69
|
@ -274,12 +274,7 @@ public class CursorableLinkedList<E> extends AbstractLinkedList<E> implements Se
|
|||
protected void registerCursor(final Cursor<E> cursor) {
|
||||
// We take this opportunity to clean the cursors list
|
||||
// of WeakReference objects to garbage-collected cursors.
|
||||
for (final Iterator<WeakReference<Cursor<E>>> it = cursors.iterator(); it.hasNext();) {
|
||||
final WeakReference<Cursor<E>> ref = it.next();
|
||||
if (ref.get() == null) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
cursors.removeIf(ref -> ref.get() == null);
|
||||
cursors.add(new WeakReference<>(cursor));
|
||||
}
|
||||
|
||||
|
|
|
@ -261,14 +261,10 @@ public class ListOrderedSet<E>
|
|||
if (result == false) {
|
||||
return false;
|
||||
}
|
||||
if (decorated().size() == 0) {
|
||||
if (decorated().isEmpty()) {
|
||||
setOrder.clear();
|
||||
} else {
|
||||
for (final Iterator<E> it = setOrder.iterator(); it.hasNext();) {
|
||||
if (!decorated().contains(it.next())) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
setOrder.removeIf(e -> !decorated().contains(e));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue