For IntelliJ IDEA,
Android Studio or Eclipse



@Override public boolean retainAll(Collection<?> c) { boolean modified = false; try (CloseableIterator<O> it = iterator()) { while (it.hasNext()) { if (!c.contains(it.next())) { it.remove(); modified = true; } } return modified; } }
public void testEntrySetIteratorRemoveInExplicitTx() throws Exception { assertEquals(0, cache.size()); cache.put("k1", "v1"); TransactionManager tm = TestingUtil.getTransactionManager(cache); withTx(tm, () -> { try (CloseableIterator<Entry<Object, Object>> entryIterator = cache.entrySet().iterator()) { entryIterator.next(); entryIterator.remove(); assertEquals(0, cache.size()); } tm.setRollbackOnly(); return null; }); }
@Test(dataProvider = "collections") public void testIteratorRemove(Function<RemoteCache<?, ?>, CloseableIteratorCollection<?>> function) { populateCacheManager(); CloseableIteratorCollection<?> collection = function.apply(remoteCache); assertEquals(100, collection.size()); try (CloseableIterator<?> iter = collection.iterator()) { assertTrue(iter.hasNext()); assertNotNull(iter.next()); Object removed = iter.next(); assertNotNull(removed); iter.remove(); assertTrue(iter.hasNext()); } assertEquals(99, collection.size()); }
@Override public boolean remove(Object o) { try (CloseableIterator<V> it = iterator()) { while (it.hasNext()) { V next = it.next(); if (o.equals(next)) { it.remove(); return true; } } return false; } }
public void testKeySetIteratorRemoveInExplicitTx() throws Exception { assertEquals(0, cache.size()); cache.put("k1", "v1"); TransactionManager tm = TestingUtil.getTransactionManager(cache); withTx(tm, () -> { try (CloseableIterator<Object> entryIterator = cache.keySet().iterator()) { entryIterator.next(); entryIterator.remove(); assertEquals(0, cache.size()); } tm.setRollbackOnly(); return null; }); } }
@Override public boolean retainAll(Collection<?> c) { boolean modified = false; try (CloseableIterator<O> it = iterator()) { while (it.hasNext()) { if (!c.contains(it.next())) { it.remove(); modified = true; } } return modified; } }
@Override public boolean retainAll(Collection<?> c) { boolean modified = false; try (CloseableIterator<O> it = iterator()) { while (it.hasNext()) { if (!c.contains(it.next())) { it.remove(); modified = true; } } return modified; } }
@Override public boolean retainAll(Collection<?> c) { boolean modified = false; try (CloseableIterator<O> it = iterator()) { while (it.hasNext()) { if (!c.contains(it.next())) { it.remove(); modified = true; } } return modified; } }
@Override public boolean remove(Object o) { try (CloseableIterator<V> it = iterator()) { while (it.hasNext()) { V next = it.next(); if (o.equals(next)) { it.remove(); return true; } } return false; } }
@Override public boolean remove(Object o) { try (CloseableIterator<V> it = iterator()) { while (it.hasNext()) { V next = it.next(); if (o.equals(next)) { it.remove(); return true; } } return false; } }
@Override public boolean retainAll(Collection<?> c) { boolean modified = false; try (CloseableIterator<O> it = iterator()) { while (it.hasNext()) { if (!c.contains(it.next())) { it.remove(); modified = true; } } return modified; } }
@Override public boolean remove(Object o) { try (CloseableIterator<V> it = iterator()) { while (it.hasNext()) { V next = it.next(); if (o.equals(next)) { it.remove(); return true; } } return false; } }
@Override public boolean remove(Object o) { try (CloseableIterator<V> it = iterator()) { while (it.hasNext()) { V next = it.next(); if (o.equals(next)) { it.remove(); return true; } } return false; } }
public void testEntrySetIteratorRemoveInExplicitTx() throws Exception { assertEquals(0, cache.size()); cache.put("k1", "v1"); TransactionManager tm = TestingUtil.getTransactionManager(cache); withTx(tm, () -> { try (CloseableIterator<Entry<Object, Object>> entryIterator = cache.entrySet().iterator()) { entryIterator.next(); entryIterator.remove(); assertEquals(0, cache.size()); } tm.setRollbackOnly(); return null; }); }
public void testKeySetIteratorRemoveInExplicitTx() throws Exception { assertEquals(0, cache.size()); cache.put("k1", "v1"); TransactionManager tm = TestingUtil.getTransactionManager(cache); withTx(tm, () -> { try (CloseableIterator<Object> entryIterator = cache.keySet().iterator()) { entryIterator.next(); entryIterator.remove(); assertEquals(0, cache.size()); } tm.setRollbackOnly(); return null; }); } }