List of usage examples for java.util Set iterator
Iterator<E> iterator();
From source file:de.suse.swamp.core.data.DatasetCache.java
/** * Queries the cache for a dataset with <i>datasetName</i> * and an ID inside <i>list</i>. Called from Workflow and * Dataset that maintain a cache for their included * datasets itself. /* w w w .j a v a 2 s . c o m*/ * @return - Dataset if found, null if not. */ public Dataset getByName(Set list, String datasetName) { for (Iterator it = list.iterator(); it.hasNext();) { Integer id = (Integer) it.next(); if (cache.containsKey(id) && ((Dataset) cache.get(id)).getName().equals(datasetName)) { //Logger.DEBUG("Cache hit for Dset: " + datasetName); return (Dataset) cache.get(id); } } return null; }
From source file:org.biopax.validator.rules.BindingFeatureExtraRules.java
public void check(final Validation validation, Model model) { Set<BindingFeature> bfs = new HashSet<BindingFeature>(model.getObjects(BindingFeature.class)); Cluster<BindingFeature> groupping = new Cluster<BindingFeature>() { @Override/*from w w w . ja v a 2 s . c o m*/ public boolean match(BindingFeature a, BindingFeature b) { boolean ab = a.getBindsTo() != null && b.getBindsTo() != null && a.getBindsTo().isEquivalent(b.getBindsTo()); return !a.isEquivalent(b) && ab; } }; Set<Set<BindingFeature>> violations = groupping.cluster(bfs, Integer.MAX_VALUE); // report the error once for each cluster >1 for (Set<BindingFeature> s : violations) { if (s.size() > 1) { BindingFeature a = s.iterator().next(); error(validation, a, "inverse.functional.violated", false, "bindsTo", a.getBindsTo(), s); } } }
From source file:com.panet.imeta.core.hash.ByteArrayHashMap.java
@SuppressWarnings("unchecked") public List<byte[]> getKeys() { List<byte[]> rtn = new ArrayList<byte[]>(this.size()); Set<byte[]> kSet = this.keySet(); for (Iterator<byte[]> it = kSet.iterator(); it.hasNext();) { rtn.add(it.next());/*from w ww.j a v a2 s . c o m*/ } return rtn; }
From source file:org.biopax.validator.rules.EntityReferenceSamePhysicalEntitiesRule.java
public void check(final Validation validation, EntityReference eref) { Set<Set<SimplePhysicalEntity>> clasters = algorithm.cluster(eref.getEntityReferenceOf(), Integer.MAX_VALUE); // report the error case once per cluster for (Set<SimplePhysicalEntity> col : clasters) { if (col.size() > 1) { SimplePhysicalEntity u = col.iterator().next(); col.remove(u);/*from ww w. j a v a 2 s. co m*/ error(validation, eref, "same.state.entity", false, u, col); } } }
From source file:epgtools.dumpepgfromts.dataextractor.channel.ChannelDataExtractorTest.java
/** * Test of getChannels method, of class ChannelDataExtractor. *//*from www .j av a2s . co m*/ @Test public void testGetChannels() throws DecoderException { LOG.info(""); Section sec = TestSection.getSdt1(); ChannelDataExtractor instance = new ChannelDataExtractor(); instance.makeDataSet(sec); Set<Channel> set = instance.getUnmodifiableDataSet(); assertTrue(set.size() == 1); Channel ch = set.iterator().next(); assertEquals(ch.getDisplay_name(), ""); }
From source file:hudson.plugins.memegen.MemegeneratorResponseException.java
protected URL buildURL(String action, HashMap<String, String> map) throws MalformedURLException, IOException { String getVars = ""; Set s = map.entrySet(); Iterator i = s.iterator(); while (i.hasNext()) { Map.Entry var = (Map.Entry) i.next(); getVars += URLEncoder.encode((String) var.getKey(), "UTF-8") + "=" + URLEncoder.encode((String) var.getValue(), "UTF-8") + "&"; }//from ww w . j a v a2 s .c o m URL url = new URL(APIURL + "/" + action + "?" + getVars); return url; }
From source file:org.biopax.validator.rules.DuplicateIdCaseInsensitiveRule.java
public void check(final Validation validation, Model model) { Cluster<BioPAXElement> algorithm = new Cluster<BioPAXElement>() { @Override/*from w w w .jav a2 s.c o m*/ public boolean match(BioPAXElement a, BioPAXElement b) { return !a.equals(b) && a.getUri().equalsIgnoreCase(b.getUri()); } }; Set<Set<BioPAXElement>> clasters = algorithm.cluster(model.getObjects(), Integer.MAX_VALUE); // report the error once for each cluster for (Set<BioPAXElement> duplicates : clasters) { if (duplicates.size() > 1) { BioPAXElement u = duplicates.iterator().next(); duplicates.remove(u); // keep the first element error(validation, u, "duplicate.id.ignoringcase", false, duplicates, u.getModelInterface().getSimpleName()); } } }
From source file:hudson.plugins.clearcase.ConfigSpecTest.java
@Test public void testExtractLoadRulesUnix() throws IOException { String rawCs = org.apache.commons.io.IOUtils .toString(getClass().getResourceAsStream("ct-catcs-2-CRLF.log")); ConfigSpec cs = new ConfigSpec(rawCs, true); Set<String> loadRules = cs.getLoadRules(); assertEquals(1, loadRules.size());//from w w w . j a v a 2 s . co m assertEquals("/a/b", loadRules.iterator().next()); }
From source file:cop.maven.plugins.RamlMojoTest.java
@Test(groups = "getSourceDirectories") public void shouldReturnProjectBuildSourcePathWhenSourceDirectoryEmpty() throws Exception { mojo.project.getBuild().setSourceDirectory("aaa/bbb"); Set<File> files = mojo.getSourceDirectories(); assertThat(files).hasSize(1);//from ww w . j a va2 s . c o m assertThat(files.iterator().next().getPath()).isEqualTo(FilenameUtils.normalize("aaa/bbb")); }
From source file:hudson.plugins.clearcase.ConfigSpecTest.java
@Test public void testExtractLoadRulesWindows() throws IOException { String rawCs = org.apache.commons.io.IOUtils .toString(getClass().getResourceAsStream("ct-catcs-2-CRLF.log")); ConfigSpec cs = new ConfigSpec(rawCs, false); Set<String> loadRules = cs.getLoadRules(); assertEquals(1, loadRules.size());/*w w w .j a v a2 s. co m*/ assertEquals("\\a\\b", loadRules.iterator().next()); }