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) {
|
protected void registerCursor(final Cursor<E> cursor) {
|
||||||
// We take this opportunity to clean the cursors list
|
// We take this opportunity to clean the cursors list
|
||||||
// of WeakReference objects to garbage-collected cursors.
|
// of WeakReference objects to garbage-collected cursors.
|
||||||
for (final Iterator<WeakReference<Cursor<E>>> it = cursors.iterator(); it.hasNext();) {
|
cursors.removeIf(ref -> ref.get() == null);
|
||||||
final WeakReference<Cursor<E>> ref = it.next();
|
|
||||||
if (ref.get() == null) {
|
|
||||||
it.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cursors.add(new WeakReference<>(cursor));
|
cursors.add(new WeakReference<>(cursor));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -261,14 +261,10 @@ public class ListOrderedSet<E>
|
||||||
if (result == false) {
|
if (result == false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (decorated().size() == 0) {
|
if (decorated().isEmpty()) {
|
||||||
setOrder.clear();
|
setOrder.clear();
|
||||||
} else {
|
} else {
|
||||||
for (final Iterator<E> it = setOrder.iterator(); it.hasNext();) {
|
setOrder.removeIf(e -> !decorated().contains(e));
|
||||||
if (!decorated().contains(it.next())) {
|
|
||||||
it.remove();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue