List of usage examples for java.util Iterator remove
default void remove()
From source file:net.easysmarthouse.sheduler.SimpleSchedulerImpl.java
void pushCompletedCycleTasks() { synchronized (cycleTasks) { Iterator<TaskContainer> iterator = cycleTasks.iterator(); while (iterator.hasNext()) { TaskContainer container = iterator.next(); if (isCompleted(container)) { if (!isCycleTask(container)) { iterator.remove(); }/*w w w . j av a2s . c o m*/ taskProcessor.updateTask(container); try { taskQueue.put(container); } catch (InterruptedException ex) { logger.error("Cycle task execution failed.", ex); } } } } }
From source file:com.twitter.hraven.hadoopJobMonitor.jmx.WhiteList.java
synchronized void referesh() { Date now = new Date(); Iterator<Map.Entry<String, Date>> iterator = expirationMap.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry<String, Date> entry = iterator.next(); if (entry.getValue().before(now)) { LOG.warn("Removing stale entry from the white list: " + entry); iterator.remove(); }//from www. j a v a 2 s . c om } }
From source file:com.enitalk.controllers.bots.FillWordsRunnable.java
public void sendCandidates(String url, Integer type) { try {//from ww w.j a v a2s. c o m Response json = Request.Get(url).execute(); String rs = json.returnContent().asString(); JsonNode randomContent = jackson.readTree(rs); Iterator<JsonNode> els = randomContent.elements(); while (els.hasNext()) { ObjectNode el = (ObjectNode) els.next(); if (Character.isUpperCase(el.path("word").asText().charAt(0)) || StringUtils.contains(el.path("word").asText(), " ")) { els.remove(); } else { el.put("type", type); rabbit.send("words", MessageBuilder.withBody(jackson.writeValueAsBytes(el)).build()); } } } catch (Exception e) { logger.error(ExceptionUtils.getFullStackTrace(e)); } }
From source file:fr.univnantes.lina.UIMAProfiler.java
private void removeRandomElement(Set<Object> set) { int atIndex = new Random().nextInt(set.size()); int k = 0;//from w w w. j av a2s. co m Iterator<Object> it = set.iterator(); it.next(); while (k < atIndex) { k++; it.next(); } it.remove(); }
From source file:com.gargoylesoftware.htmlunit.javascript.host.xml.FormData.java
/** * Removes the entry (if exists).//from w w w . ja va2s .co m * @param name the name of the field to remove */ @JsxFunction(functionName = "delete", value = { @WebBrowser(value = FF, minVersion = 45), @WebBrowser(CHROME) }) public void delete_js(final String name) { if (StringUtils.isEmpty(name)) { return; } final Iterator<NameValuePair> iter = requestParameters_.iterator(); while (iter.hasNext()) { final NameValuePair pair = iter.next(); if (name.equals(pair.getName())) { iter.remove(); } } }
From source file:com.vmware.identity.openidconnect.server.SlidingWindowMap.java
private void cleanUp(Date now) { // the oldest items are at the head of the queue, as long as we see expired items we continue removing Iterator<Entry<K, Pair<V, Date>>> iterator = this.map.entrySet().iterator(); while (iterator.hasNext()) { Entry<K, Pair<V, Date>> entry = iterator.next(); Date insertionDate = entry.getValue().getRight(); if (now.after(new Date(insertionDate.getTime() + this.widthMilliseconds))) { iterator.remove(); } else {/*from w ww . j av a 2s. c o m*/ break; } } }
From source file:eu.europa.ec.fisheries.uvms.spatial.service.bean.impl.UserAreaServiceBean.java
@Override public List<eu.europa.ec.fisheries.uvms.spatial.service.dto.area.UserAreaDto> searchUserAreasByCriteria( String userName, String scopeName, String searchCriteria, boolean isPowerUser) throws ServiceException { List<UserAreasEntity> userAreas = repository.listUserAreaByCriteria(userName, scopeName, searchCriteria, isPowerUser);// ww w . java 2s .c o m final List<eu.europa.ec.fisheries.uvms.spatial.service.dto.area.UserAreaDto> userAreaDtos = new ArrayList<>(); Iterator it = userAreas.iterator(); while (it.hasNext()) { UserAreasEntity next = (UserAreasEntity) it.next(); it.remove(); // avoids a ConcurrentModificationException Geometry geom = next.getGeom(); if (geom != null) { Geometry envelope = next.getGeom().getEnvelope(); userAreaDtos.add(new eu.europa.ec.fisheries.uvms.spatial.service.dto.area.UserAreaDto(next.getId(), next.getName(), StringUtils.isNotBlank(next.getAreaDesc()) ? next.getAreaDesc() : StringUtils.EMPTY, GeometryMapper.INSTANCE.geometryToWkt(envelope).getValue(), next.getUserName())); } } return userAreaDtos; }
From source file:simMPLS.scenario.TExternalLink.java
/** * Este mtodo reinicia los atributos de la clase, dejando la instancia como si se * acabase de crear por el constructor.//from w ww . j a v a 2s . c o m * @since 1.0 */ public void reset() { this.cerrojo.lock(); Iterator it = this.getBuffer().iterator(); while (it.hasNext()) { it.next(); it.remove(); } this.cerrojo.unLock(); this.cerrojoLlegados.lock(); it = this.bufferLlegadosADestino.iterator(); while (it.hasNext()) { it.next(); it.remove(); } this.cerrojoLlegados.unLock(); ponerEnlaceCaido(false); }
From source file:com.compomics.colims.repository.impl.QuantificationReagentHibernateRepository.java
@Override public List<QuantificationReagent> findByExample(QuantificationReagent exampleInstance) { List<QuantificationReagent> quantificationReagents = super.findByExample(exampleInstance); Iterator<QuantificationReagent> iterator = quantificationReagents.iterator(); // do some additional comparisons while (iterator.hasNext()) { QuantificationReagent quantificationReagent = iterator.next(); //check accession if (!exampleInstance.getAccession().equals(quantificationReagent.getAccession())) { iterator.remove(); continue; }// www. j a v a 2s.co m //check label if (!exampleInstance.getLabel().equals(quantificationReagent.getLabel())) { iterator.remove(); continue; } //check name if (!exampleInstance.getName().equals(quantificationReagent.getName())) { iterator.remove(); continue; } } return quantificationReagents; }
From source file:com.formkiq.core.service.generator.pdfbox.TextToPDFieldMapper.java
/** * Remove Non Printable Characters and extra spaces. * @param textPositions {@link List} of {@link TextPosition} * @return {@link List} of {@link TextPosition} *///from ww w . j av a 2 s . c o m private List<TextPosition> removeNonPrintableAndExtraSpaces(final List<TextPosition> textPositions) { List<TextPosition> list = textPositions.stream() .filter(s -> cleanTextContent(s.getUnicode()).equals(s.getUnicode())).collect(Collectors.toList()); int c = 0; Iterator<TextPosition> itr = list.iterator(); while (itr.hasNext()) { TextPosition tp = itr.next(); if (isEmpty(tp.getUnicode().trim())) { c++; if (c > 2) { itr.remove(); } } else { c = 0; } } return list; }