List of usage examples for java.util Iterator remove
default void remove()
From source file:de.unirostock.sems.cbarchive.web.dataholder.WorkspaceHistory.java
public void removeWorkspaceFromHistory(String workspaceId) { Iterator<Workspace> workspaceIterator = recentWorkspaces.iterator(); while (workspaceIterator.hasNext()) { Workspace elem = workspaceIterator.next(); if (elem.getWorkspaceId().equals(workspaceId)) workspaceIterator.remove(); }/*from w w w .java2 s. c om*/ }
From source file:org.wallride.support.CategoryUtils.java
private void createNode(TreeNode<Category> parent, Collection<Category> Categories) { List<TreeNode<Category>> children = new ArrayList<>(); Iterator<Category> i = Categories.iterator(); while (i.hasNext()) { Category Category = i.next();/*from ww w . ja v a2 s . c om*/ TreeNode<Category> node = new TreeNode<>(Category); node.setParent(parent); if (parent.getObject().equals(Category.getParent())) { children.add(node); i.remove(); } } parent.setChildren(children); for (TreeNode<Category> node : children) { createNode(node, Categories); } }
From source file:eu.larkc.RDFPig.optimizers.strategies.SamplePruneOptimizationStrategy.java
@Override public void prune(ArrayList<Set<TupleCostPair>> searchSpace, Executor executor, CostCalculator calculator) { // Only sample up to MAXSAMPLINGCYCLES steps int maxSamplingCycles = Configuration.getInstance().getPropertyInt(Configuration.MAXSAMPLINGCYCLES); if (searchSpace.size() > maxSamplingCycles) { return;/*from w ww . ja va2 s . co m*/ } logger.info("Calling SamplePrune for cycle: " + searchSpace.size()); // Sort last calculated expressions by cost Set<TupleCostPair> currentLevel = searchSpace.get(searchSpace.size() - 1); if (currentLevel.isEmpty()) { logger.warn("Empty current level, searchSpace sizes: "); for (Set<TupleCostPair> s : searchSpace) { logger.warn(Integer.toString(s.size())); } return; } List<TupleCostPair> sortedByCost = new ArrayList<TupleCostPair>(currentLevel); Collections.sort(sortedByCost, new Comparator<TupleCostPair>() { @Override public int compare(TupleCostPair o1, TupleCostPair o2) { if (o1.cost == o2.cost) return 0; else return o1.cost > o2.cost ? 1 : -1; } }); // TODO adapt pruning to stddev? // Prune the bottom part double staticPruneRatio = Configuration.getInstance() .getPropertyDouble(Configuration.DYNAMICPROGRAMMINGSTATICPRUNEBEFORE); int staticPruneIndex = (int) Math.ceil(sortedByCost.size() / staticPruneRatio); if (staticPruneIndex == sortedByCost.size()) staticPruneIndex--; sortedByCost = sortedByCost.subList(0, staticPruneIndex); // Sample the remaining ones Set<TupleExpr> candidates = new HashSet<TupleExpr>(); for (TupleCostPair t : sortedByCost) { candidates.add(t.tuple); } try { executor.execute(candidates, Configuration.getInstance().getPropertyDouble(Configuration.SAMPLE_RATE)); } catch (Exception e) { throw new RuntimeException("Could not sample", e); } // Update costs and remove the unsampled ones from the search space Iterator<TupleCostPair> it = currentLevel.iterator(); while (it.hasNext()) { TupleCostPair c = it.next(); if (candidates.contains(c.tuple)) c.cost = calculator.getCost(c.tuple); else it.remove(); } logger.info("Sample-Prune done for level " + (searchSpace.size() - 1) + " current level size = " + currentLevel.size()); }
From source file:com.adaptris.core.services.splitter.LineCountSplitterTest.java
public void testIterator_Remove() throws Exception { MessageSplitterImp splitter = new LineCountSplitter(1); try (com.adaptris.core.util.CloseableIterable<AdaptrisMessage> iterable = com.adaptris.core.util.CloseableIterable .ensureCloseable(splitter.splitMessage(msg))) { Iterator<AdaptrisMessage> first = iterable.iterator(); try {/*from w w w .j a v a 2s. c om*/ if (first.hasNext()) first.next(); first.remove(); fail(); } catch (UnsupportedOperationException expected) { } } }
From source file:de.tudarmstadt.ukp.experiments.argumentation.comments.pipeline.VocabularyCollector.java
@Override public void collectionProcessComplete() throws AnalysisEngineProcessException { super.collectionProcessComplete(); getLogger().info("Original vocabulary size: " + this.vocabulary.size()); // remove all with low occurrence Iterator<Map.Entry<String, Integer>> iterator = vocabulary.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry<String, Integer> next = iterator.next(); // remove if (next.getValue() < this.minimalOccurrence) { iterator.remove(); }//from www . j a v a 2 s. c o m } getLogger().info("Filtered vocabulary size: " + this.vocabulary.size()); // serialize to file try { ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(this.modelLocation)); oos.writeObject(vocabulary); } catch (IOException e) { throw new AnalysisEngineProcessException(e); } }
From source file:edu.umich.robot.soar.OutputLink.java
void destroy() { Iterator<Map.Entry<Long, OLCommandPair>> iter = commands.entrySet().iterator(); while (iter.hasNext()) { Map.Entry<Long, OLCommandPair> entry = iter.next(); entry.getValue().command.dispose(); iter.remove(); }/* ww w. jav a2 s . c om*/ }
From source file:com.company.common.dao.impl.GennericDaoImpl.java
@Override public List<T> findByDynamicField(Class<T> entityClass, Map<String, Object> hasValue) { StringBuilder sql = new StringBuilder().append(" where 1=1 "); Iterator it = hasValue.entrySet().iterator(); while (it.hasNext()) { Map.Entry pairs = (Map.Entry) it.next(); System.out.println(pairs.getKey() + " = " + pairs.getValue()); sql.append(" and ").append("c.").append(pairs.getKey()).append(" = ").append(pairs.getValue()); it.remove(); }//w w w . j av a 2s . co m List t = getHibernateTemplate() .find("select c from " + entityClass.getSimpleName() + " c " + sql.toString()); return t; }
From source file:org.cloudfoundry.tools.timeout.ReplayingTimeoutProtectionStrategy.java
/** * Cleanup any started monitors that may have never received a poll. This can happen if the client is closed after a * timeout but before a poll./* ww w .ja v a 2s . c om*/ */ private void purgeUnpolledRequests() { Iterator<Map.Entry<String, MonitorFactory>> iterator = this.completedRequests.entrySet().iterator(); while (iterator.hasNext()) { if (iterator.next().getValue().isPurgable(this.threshold + this.failTimeout)) { iterator.remove(); } } }
From source file:de.dhke.projects.cutil.collections.aspect.AspectMapKeySetTest.java
@Test public void testIteratorRemove() { final List<String> testList = new ArrayList<>(Arrays.asList("A", "B", "C", "D")); Iterator<String> iter = _keySet.iterator(); String key = iter.next();/*from ww w . j a v a 2s .c o m*/ iter.remove(); testList.removeAll(_keySet); assertEquals(1, testList.size()); assertTrue(testList.contains(key)); assertEquals(1, _listener.beforeRemoveEvents.size()); assertEquals(new DefaultMapEntry<>("A", "1"), _listener.beforeRemoveEvents.get(0).getItem()); assertEquals(1, _listener.afterRemoveEvents.size()); assertEquals(new DefaultMapEntry<>("A", "1"), _listener.afterRemoveEvents.get(0).getItem()); }
From source file:com.google.code.ssm.test.svc.AppUserServiceImpl.java
@Override public List<AppUser> getInstalledList(final int userId, final List<Integer> applicationsIds) { Collections.sort(applicationsIds); List<AppUser> applicationUsers = getDao().getList(userId, applicationsIds); Iterator<AppUser> iter = applicationUsers.iterator(); AppUser appUser = null;// w ww . jav a 2 s . c o m while (iter.hasNext()) { appUser = iter.next(); if (appUser == null || !appUser.isEnabled()) { iter.remove(); } } return applicationUsers; }