List of usage examples for java.util Iterator remove
default void remove()
From source file:modalLogic.tableau.World.java
/** * Remove clashes of a given literal.//w w w. jav a 2 s . c om * * @param literal the literal */ private void removeClashes(LabelledFormula<P> literal) { Iterator<Pair<LabelledFormula<P>>> clash = clashes.iterator(); while (clash.hasNext()) { if (clash.next().contains(literal)) { clash.remove(); } } }
From source file:com.almende.dht.Bucket.java
/** * Seen node.// w ww . j a v a 2 s . com * * @param node * the node */ public void seenNode(final Node node) { synchronized (nodes) { if (nodes.containsKey(node.getKey())) { nodes.remove(node.getKey()); nodes.put(node.getKey(), node); } else if (nodes.size() < Constants.K) { nodes.put(node.getKey(), node); } else { // get first Node through iterator, do Ping(), wait, on answer // within timeout drop key; else drop first Node, recurse // seenNode(); // LOG.warning("Bucket full:"+this.meta.rank+ " dropping oldest (not yet doing ping)"); synchronized (nodes) { Iterator<Entry<Key, Node>> iter = nodes.entrySet().iterator(); iter.next(); iter.remove(); nodes.put(node.getKey(), node); } } meta.setLastUpdate(System.currentTimeMillis()); } }
From source file:com.livgrhm.kansas.resources.AuthResource.java
private void addToAuthList(String email, String hash, java.sql.Date now, String ip) { // clear any hashmap entries for this userId HashMap authMapInst = this.authMap.getAuthMap(); Iterator i = authMapInst.entrySet().iterator(); while (i.hasNext()) { Map.Entry item = (Map.Entry) i.next(); AuthItem ai = (AuthItem) item.getValue(); if (ai.email.equals(email)) { i.remove(); }//from w w w. ja va2 s . com } // now add the new key entry AuthItem ai = new AuthItem(); ai.email = email; ai.loginDate = now; ai.ipAddress = ip; authMapInst.put(hash, ai); System.out.println("PUT IN AUTHMAP HASH: " + hash); System.out.println("AUTHMAP SIZE: " + authMapInst.size()); this.authMap.setAuthMap(authMapInst); }
From source file:io.neba.core.resourcemodels.metadata.ResourceModelMetaDataRegistrar.java
public void remove(Bundle bundle) { Map<Class<?>, ResourceModelMetadataHolder> newCache = copyCache(); Iterator<Map.Entry<Class<?>, ResourceModelMetadataHolder>> it = newCache.entrySet().iterator(); while (it.hasNext()) { OsgiBeanSource<?> source = it.next().getValue().source; if (source.getBundleId() == bundle.getBundleId()) { it.remove(); }//from w ww . ja v a 2 s .co m } this.cache = newCache; }
From source file:de.msg.terminfindung.core.erstellung.impl.AwfTerminfindungErstellen.java
/** * Bereinigt die Zeitrume in der bergebenen Liste von Terminen. Leere Zeitrume (ohne Beschreibung) werden * gelscht. Wenn fr einen Tag kein Zeitraum vorhanden ist, wird der gesamte Tag gelscht. * * @param termine Die Liste der Termine//from w w w .ja va2s . co m */ private void bereinigeZeitraeumeInTerminliste(List<Tag> termine) { // Durchlaufe die bergebene Liste der Termine Tag tag; Zeitraum zeitraum; // Durchlaufe fr jeden Tag die Liste der Zeitrume Iterator<Tag> iterTermin = termine.iterator(); while (iterTermin.hasNext()) { tag = iterTermin.next(); boolean allEmpty = true; Iterator<Zeitraum> iterZeitraum = tag.getZeitraeume().iterator(); while (iterZeitraum.hasNext()) { zeitraum = iterZeitraum.next(); if (StringUtils.isBlank(zeitraum.getBeschreibung())) { iterZeitraum.remove(); } else { allEmpty = false; } } if (allEmpty) { iterTermin.remove(); } } }
From source file:org.openmrs.module.providermanagement.page.controller.SimilarPeoplePageController.java
public String controller(PageModel pageModel, @RequestParam(value = "name", required = true) String name, UiUtils ui) throws PersonIsNotProviderException { // first find any similar providers and persons List<Person> similarProviders = new ArrayList<Person>(); List<Person> similarPeople; // don't bother searching if the name is less than 3 characters if (name != null && name.length() > 2) { similarPeople = Context.getPersonService().getPeople(name, false); // if there are no similar persons, go directly to the create provider page if (similarPeople == null || similarPeople.size() == 0) { return "redirect:" + new Redirect("providermanagement", "providerCreate", "name=" + name).getUrl(); }/*from w ww. java 2s . c o m*/ // otherwise, split into two lists, one of providers and the other of persons Iterator<Person> i = similarPeople.iterator(); while (i.hasNext()) { Person p = i.next(); if (Context.getService(ProviderManagementService.class).isProvider(p)) { similarProviders.add(p); i.remove(); } } // the get people search doesn't appear to sort by name, so we do that here Collections.sort(similarPeople, new PersonByFirstNameComparator()); Collections.sort(similarProviders, new PersonByFirstNameComparator()); // add the lists, as well as the original name, to the page model // (note that we have to convert similarProviders to a simple object so that we can pick up the associated provider attributes; similarPersons is fine as-is) pageModel.addAttribute("similarPeople", similarPeople); pageModel.addAttribute("similarProviders", ProviderManagementWebUtil.convertPersonListToSimpleObjectList(similarProviders, ui, ProviderManagementGlobalProperties.GLOBAL_PROPERTY_PROVIDER_SEARCH_DISPLAY_FIELDS() .values().toArray(new String[0]))); pageModel.addAttribute("name", name); // add the global properties that specifies the fields to display in the provider and patient search results pageModel.addAttribute("providerSearchDisplayFields", ProviderManagementGlobalProperties.GLOBAL_PROPERTY_PROVIDER_SEARCH_DISPLAY_FIELDS()); pageModel.addAttribute("personSearchDisplayFields", ProviderManagementGlobalProperties.GLOBAL_PROPERTY_PERSON_SEARCH_DISPLAY_FIELDS()); // in this case we just want to use the default page view, so return null return null; } else { return "redirect:" + new Redirect("providermanagement", "providerCreate", "name=" + name).getUrl(); } }
From source file:com.linkedin.kmf.KafkaMonitor.java
private void checkHealth() { Iterator<Map.Entry<String, App>> testIt = _tests.entrySet().iterator(); while (testIt.hasNext()) { Map.Entry<String, App> entry = testIt.next(); if (!entry.getValue().isRunning()) { LOG.error("Test " + entry.getKey() + " has stopped."); testIt.remove(); }// w w w . j a va 2s . c o m } Iterator<Map.Entry<String, Service>> serviceIt = _services.entrySet().iterator(); while (serviceIt.hasNext()) { Map.Entry<String, Service> entry = serviceIt.next(); if (!entry.getValue().isRunning()) { LOG.error("Service " + entry.getKey() + " has stopped."); serviceIt.remove(); } } }
From source file:com.expedia.seiso.domain.service.search.Validator.java
private boolean setValidTokens(SearchQuery tokenizedSearchQuery, ConstraintValidatorContext context) { boolean isValid = true; Set<String> tokens = this.tokenizer.tokenize(tokenizedSearchQuery.getQuery()); Iterator<String> searchQueryIterator = tokens.iterator(); while (searchQueryIterator.hasNext()) { String searchTerm = searchQueryIterator.next(); if (!this.tokenPattern.matcher(searchTerm).matches()) { searchQueryIterator.remove(); this.addConstraintViolation(context, "removed search term '" + searchTerm + "' because it does not match pattern " + this.tokenPattern.pattern()); }/*from w ww. j a va 2 s. c om*/ } if (tokens.size() < 1) { isValid = false; this.addConstraintViolation(context, "no valid search terms"); } tokenizedSearchQuery.setTokens(tokens); return isValid; }
From source file:de.dhke.projects.cutil.collections.map.MapKeySetEntrySet.java
@Override public boolean retainAll(Collection<?> c) { boolean removed = false; Iterator<Entry<K, V>> iter = iterator(); while (iter.hasNext()) { final Entry<K, V> entry = iter.next(); if (!c.contains(entry)) { removed = true;//from w w w. j a v a2 s.c om iter.remove(); } } return removed; }
From source file:de.dhke.projects.cutil.collections.map.MapKeySetEntrySet.java
@Override public boolean removeAll(Collection<?> c) { boolean removed = false; Iterator<Entry<K, V>> iter = iterator(); while (iter.hasNext()) { final Entry<K, V> entry = iter.next(); if (c.contains(entry)) { removed = true;/* w w w. j a v a 2 s. co m*/ iter.remove(); } } return removed; }