List of usage examples for java.util Iterator remove
default void remove()
From source file:edu.csun.ecs.cs.multitouchj.application.whiteboard.ui.InteractiveCanvas.java
protected void drawPoints() { synchronized (previousPoints) { synchronized (resizableBufferedImage) { // clear points for pen if it's been long since last changed long currentTime = new Date().getTime(); for (int id : pens.keySet()) { if (previousTimes.containsKey(id)) { long time = previousTimes.get(id); if ((currentTime - time) > POINT_CLEAR_DURATION) { previousPoints.remove(id); previousTimes.remove(id); }/*from w w w .ja v a2 s . co m*/ } } DisplayMode displayMode = getWindowManager().getDisplayManager().getCurrentDisplayMode(); BufferedImage bufferedImage = resizableBufferedImage.getBufferedImage(); Graphics2D graphics = bufferedImage.createGraphics(); for (int id : pens.keySet()) { Pen pen = pens.get(id); LinkedList<Point> points = previousPoints.get(id); if ((pen != null) && (points != null) && (points.size() > 1)) { log.debug("id: " + id + ", points: " + points.size()); Point previousPoint = points.removeFirst(); Iterator<Point> iterator = points.iterator(); while (iterator.hasNext()) { Point point = iterator.next(); if (iterator.hasNext()) { iterator.remove(); } graphics.setStroke(pen.getStroke()); graphics.setPaint(pen.getPaint()); graphics.drawLine((int) Math.floor(previousPoint.getX()), (displayMode.getHeight() - (int) Math.floor(previousPoint.getY())), (int) Math.floor(point.getX()), (displayMode.getHeight() - (int) Math.floor(point.getY()))); previousPoint = point; } setDirty(true); } } graphics.dispose(); } } }
From source file:org.openinfinity.tagcloud.domain.repository.TargetRepositoryMongoDBImpl.java
private void removeResultsOutsideBounds(CoordinateBounds b, GeoResults<Target> results) { Iterator<GeoResult<Target>> iterator = results.getContent().iterator(); while (iterator.hasNext()) { GeoResult<Target> result = iterator.next(); Target target = result.getContent(); if (target.getLocation()[0] < b.getsWLng() || target.getLocation()[0] > b.getnELng() || target.getLocation()[1] < b.getsWLat() || target.getLocation()[1] > b.getnELat()) iterator.remove(); }/* ww w. j a v a2 s. com*/ }
From source file:br.ufba.dcc.mestrado.computacao.service.impl.OpenHubProjectServiceImpl.java
@Override @Transactional/* www .j a va 2 s .co m*/ public void reloadTagsFromDatabase(OpenHubProjectEntity entity) throws Exception { if (entity != null && entity.getTags() != null) { Set<OpenHubTagEntity> tagList = new HashSet<OpenHubTagEntity>(); Iterator<OpenHubTagEntity> tagIterator = entity.getTags().iterator(); while (tagIterator.hasNext()) { OpenHubTagEntity tag = tagIterator.next(); OpenHubTagEntity already = tagRepository.findByName(tag.getName()); if (already != null) { tagIterator.remove(); } else { tag.setId(null); already = tagRepository.save(tag); } tagList.add(already); } entity.getTags().clear(); entity.getTags().addAll(tagList); } }
From source file:de.dhke.projects.cutil.collections.aspect.AspectMultiMapValueCollectionTest.java
/** * Test of iterator method, of class AspectMultiMapValueCollection. *///from ww w .j av a 2 s . c om @Test public void testIterator_remove_veto() { _listener.vetoRemove = true; Iterator<String> iter = _values.iterator(); iter.next(); try { iter.remove(); fail("Remove veto not raised"); } catch (AssertionError ex) { /* ignore */ } assertTrue(_listener.beforeRemoveEvents.isEmpty()); assertTrue(_listener.afterRemoveEvents.isEmpty()); assertTrue(_values.contains("a")); assertTrue(_values.contains("A")); assertTrue(_values.contains("b")); assertTrue(_values.contains("B")); assertTrue(_values.contains("c")); assertTrue(_values.contains("C")); assertFalse(_values.contains("d")); assertFalse(_values.contains("D")); }
From source file:com.clustercontrol.repository.util.FacilityTreeCache.java
/** * ????//w w w . j a v a2s . com * */ private static void getFacilityTreeRecursive(FacilityTreeItem facilityTreeItem, List<String> roleIdList) { Iterator<FacilityTreeItem> iter = facilityTreeItem.getChildren().iterator(); while (iter.hasNext()) { FacilityTreeItem childItem = iter.next(); HashSet<String> roleIdSet = childItem.getAuthorizedRoleIdSet(); if (roleIdSet == null || !hasAnyCommonRoleId(roleIdSet, roleIdList)) { childItem.getData().setNotReferFlg(true); } else { childItem.getData().setNotReferFlg(false); } getFacilityTreeRecursive(childItem, roleIdList); // ??????????????? if (childItem.getData().isNotReferFlg() && childItem.getChildren().size() == 0) { iter.remove(); } } }
From source file:geva.Operator.Operations.LSystemSelect.java
@Override public void doOperation(List<Individual> operands) { List<Individual> valids = new LinkedList<Individual>(); String[] arrayPheno = new String[operands.size()]; String[] arrayDepth = new String[operands.size()]; String[] arrayAngle = new String[operands.size()]; double[] arrayFitns = new double[operands.size()]; int[] fitness = new int[operands.size()]; guiComp gui;//from w w w .j a va 2s .c o m int count = 0; String outPop = ""; // Make a list of valid operands only for (Individual operand : operands) { if (operand.isValid() == true) { valids.add(operand); } } // Exit if there are no valids if (valids.size() == 0) { return; } // Bring the list up to the required size by duplicating valids while (valids.size() < operands.size()) { valids.add(valids.get(rng.nextInt(valids.size()))); } //reset iterator to run through updated list of individuals to create //map of specific phenotype strings. for (Individual ind : valids) { arrayDepth[count] = ind.getPhenotype().getString().substring(0, 1); arrayAngle[count] = ind.getPhenotype().getString().substring(1, 6); arrayPheno[count] = ind.getPhenotype().getString().substring(6); arrayFitns[count] = ind.getFitness().getDouble(); if (arrayPheno[count].length() > 200 && Integer.parseInt(arrayDepth[count]) > 3) arrayDepth[count] = "3"; count++; } //create instance of the gui and pass phenotype string map gui = new guiComp(arrayPheno, arrayDepth, arrayAngle, arrayFitns, count, ++generation, generations); while (gui.stillRunning() == true) { try { synchronized (gui) { gui.wait(1000); } } catch (InterruptedException e) { } } //getting the fitness' once generate is pressed fitness = gui.getGELSYSFitness(); gui.setVisible(false); gui.dispose(); gui = null; if (fitness == null) { logger.warn("not working!"); } else { //assigning the relevant fitnes' to their genotype in operands list int current = 0; String tempOut[] = new String[valids.size()]; for (Individual ind : valids) { //System.out.println("fitness: "+fitness[current]); if (fitness[current] == guiComp.LF_FIT) { ind.getFitness().setDouble(ind.getFitness().getDouble() * 0.99); super.selectedPopulation.add(ind.clone()); //System.err.println(ind.getFitness().getDouble()); parents.add(ind); tempOut[current] = ind.getPhenotype().toString(); outPop = outPop + "\n" + ind.getPhenotype().toString(); } else if (fitness[current] == guiComp.LF_UNFIT) { Iterator<Individual> itor; for (itor = operands.iterator(); itor.hasNext() == true;) { Individual i = itor.next(); if (i == ind) itor.remove(); } } current++; } } while (super.selectedPopulation.size() < 2) { super.selectedPopulation.add(valids.get(rng.nextInt(valids.size())).clone()); } List<Individual> fillPop = new ArrayList<Individual>(super.selectedPopulation.getAll()); //Make sure the selected population is the required size for replacemnt while (super.selectedPopulation.size() < super.size) { super.selectedPopulation.add(fillPop.get(rng.nextInt(fillPop.size())).clone()); } //writing the parent selections to a file. // String fileName = "output.txt"; // try{ // FileWriter fw = new FileWriter(fileName, true); // BufferedWriter bw = new BufferedWriter(fw); // bw.write(outPop); // bw.close(); // } catch (Exception ex) { // System.out.println("not writing to the "+fileName+" "+ex); // } }
From source file:org.darwinathome.server.persistence.impl.WorldHistoryImpl.java
public synchronized List<SpeechChange> getSpeechSince(String bodyName, long time) { List<SpeechChange> changes = new ArrayList<SpeechChange>(); Iterator<SpeechChange> walk = speechChanges.iterator(); while (walk.hasNext()) { SpeechChange speechChange = walk.next(); if (world().getAge() - speechChange.getTime() > Constants.SPEECH_TIME_TO_LIVE) { walk.remove(); } else if (speechChange.getTime() > time && !speechChange.getBodyName().equals(bodyName)) { changes.add(speechChange);//from www . j a v a 2s .co m } } return changes; }
From source file:com.scireum.open.cache.ManagedCache.java
@Override public void runEviction() { usesHistory.add(getUses());//from www .ja va 2 s. c om if (usesHistory.size() > MAX_HISTORY) { usesHistory.remove(0); } hitRateHistory.add(getHitRate()); if (hitRateHistory.size() > MAX_HISTORY) { hitRateHistory.remove(0); } hits.reset(); misses.reset(); lastEvictionRun = new Date(); if (timeToLive <= 0) { return; } // Remove all outdated entries... long now = System.currentTimeMillis(); Iterator<Entry<K, CacheEntry<K, V>>> iter = data.entrySet().iterator(); while (iter.hasNext()) { Entry<K, CacheEntry<K, V>> next = iter.next(); if (next.getValue().getMaxAge() == 0 || next.getValue().getMaxAge() > now) { return; } iter.remove(); } }
From source file:com.alibaba.napoli.gecko.service.impl.ReconnectManager.java
public void cancelReconnectGroup(final String group) { this.canceledGroupSet.add(group); final Iterator<ReconnectTask> it = this.tasks.iterator(); while (it.hasNext()) { final ReconnectTask task = it.next(); if (task.getGroupSet().contains(group)) { log.warn("??" + task.getGroupSet()); it.remove(); }/*from ww w. j ava 2 s . c o m*/ } }
From source file:com.amalto.core.server.MDMTransaction.java
private void transactionComplete() { synchronized (storageTransactions) { Iterator<StorageTransaction> iterator = storageTransactions.values().iterator(); while (iterator.hasNext()) { StorageTransaction storageTransaction = iterator.next(); if (!storageTransaction.hasFailed()) { iterator.remove(); } else { LOGGER.warn("Remaining failed storageTransaction while transactionComplete is called !"); //$NON-NLS-1$ }/*from www . jav a2 s . c o m*/ } if (storageTransactions.isEmpty()) { storageTransactions.clear(); ServerContext.INSTANCE.get().getTransactionManager().remove(this); } } }