List of usage examples for java.util Set iterator
Iterator<E> iterator();
From source file:com.asakusafw.runtime.directio.hadoop.HadoopDataSourceUtil.java
private static List<String> stringCrossJoin(List<Set<String>> candidates) { assert candidates != null; assert candidates.isEmpty() == false; List<String> results = new ArrayList<>(); Iterator<Set<String>> iter = candidates.iterator(); assert iter.hasNext(); results.addAll(iter.next());/*w ww. ja v a2 s. co m*/ while (iter.hasNext()) { Set<String> next = iter.next(); if (next.size() == 1) { String suffix = next.iterator().next(); for (ListIterator<String> i = results.listIterator(); i.hasNext();) { String vaule = i.next(); i.set(vaule + suffix); } } else { List<String> nextResults = new ArrayList<>(); for (String value : results) { for (String suffix : next) { nextResults.add(value + suffix); } } results = nextResults; } } return results; }
From source file:org.squale.squaleweb.util.graph.HistoMaker.java
/** * Ajoute les valeurs d'une courbe//from w ww . ja v a2 s . c o m * * @param pName nom associ la future courbe * @param pValues Map contenant en cl des date (java.util.Date) et en valeurs des nombres (Number) */ public void addCurve(String pName, Map pValues) { TimeSeries timeSeries = new TimeSeries(pName); Set keys = pValues.keySet(); Iterator it = keys.iterator(); while (it.hasNext()) { Date date = (Date) it.next(); Day day = new Day(date); timeSeries.addOrUpdate(day, (Number) pValues.get(date)); } mDataSet.addSeries(timeSeries); }
From source file:com.swcguild.dvdlibrarymvc.dao.DvdLibraryDaoDbImpl.java
@Override public List<Dvd> searchDvds(Map<SearchTerm, String> criteria) { if (criteria == null || criteria.size() == 0) { return getAllDVDs(); }/*from w w w.j av a2 s . c o m*/ StringBuilder query = new StringBuilder("SELECT * FROM contacts WHERE "); int numParams = criteria.size(); int paramPosition = 0; String[] paramVals = new String[numParams]; Set<SearchTerm> keyset = criteria.keySet(); Iterator<SearchTerm> iter = keyset.iterator(); while (iter.hasNext()) { SearchTerm currentKey = iter.next(); String currentValue = criteria.get(currentKey); if (paramPosition > 0) { query.append(" and "); } query.append(currentKey); query.append(" = ?"); paramVals[paramPosition] = currentValue; paramPosition++; } return jdbcTemplate.query(query.toString(), new ContactMapper(), paramVals); }
From source file:com.textocat.textokit.eval.anno.impl.OverlapMatchingStrategy.java
@Override public Set<AnnotationFS> searchCandidates(AnnotationFS goldAnno) { Set<AnnotationFS> result = sysOverlapIdx.getOverlapping(goldAnno.getBegin(), goldAnno.getEnd()); Iterator<AnnotationFS> resultIter = result.iterator(); while (resultIter.hasNext()) { if (!isCandidate(goldAnno, resultIter.next())) { resultIter.remove();/*from ww w .j ava2 s . c om*/ } } return result; }
From source file:com.mythesis.profileanalysis.WordVectorFinder.java
/** * a method that calculates the word vector for a specific domain * @param domain the general domain//from w w w .j a v a 2 s. c o m * @param wordVectorDirectory the directory where i will save the word vector * @param LDAdirectory LDA directory * @param nTopTopics number of top topics * @param choice how to select the top topics (1 for average, 2 for median, 3 for number of documents that have probability higher than 1/nTopics) * @param top_words number of top words * @param nTopics total number of topics */ public void getWordVector(String domain, String wordVectorDirectory, String LDAdirectory, int nTopTopics, int choice, int top_words, int nTopics) { String path = LDAdirectory; LDAtopicsWords rk = new LDAtopicsWords(); if (nTopTopics > nTopics) nTopTopics = nTopics; //get a number of top topics and a number of top words from every topic HashMap<Integer, HashMap<String, Double>> topicwordprobmap = rk.readFile(path, top_words, nTopics, nTopTopics, choice); List<String> wordVector = new ArrayList<>(); for (Integer topicindex : topicwordprobmap.keySet()) { //iterate through every topic Set keySet = topicwordprobmap.get(topicindex).keySet(); Iterator iterator = keySet.iterator(); while (iterator.hasNext()) { //iterate through every word String word = iterator.next().toString(); if (!wordVector.contains(word)) { wordVector.add(word); //put the word in word vector } } } //store the word vector File wordVectorFile = new File(wordVectorDirectory + "wordVector" + domain + ".txt"); try { FileUtils.writeLines(wordVectorFile, wordVector); } catch (IOException ex) { Logger.getLogger(WordVectorFinder.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:gov.nih.nci.caarray.security.SecurityUtils.java
private static User getOwner(Protectable p) { final Set<User> owners = getOwners(p); if (owners.isEmpty()) { return null; }//from w ww .j ava2 s.co m return owners.iterator().next(); }
From source file:com.opengsn.controller.manager.CloudManagerClient.java
/** * Update host priority list//from ww w.j a v a2 s .com * @param list */ public void updateHostPriorityTable(Map<String, Integer> list) { PrioritiesList pList = new PrioritiesList(); Set<String> keys = list.keySet(); Iterator<String> itr = keys.iterator(); while (itr.hasNext()) { String id = itr.next(); Integer num = list.get(id); IdPriority priority = new IdPriority(); priority.setId(id); priority.setPriority(num); pList.getPriorities().add(priority); } OverrideMapType overrideMap = new OverrideMapType(); overrideMap.setPrioritiesList(pList); cloudMgr.overrideHostPriorities(overrideMap); }
From source file:importer.handler.post.annotate.HTMLConverter.java
public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException { Set<Element> keys = map.keySet(); Iterator<Element> iter = keys.iterator(); Element best = null;/*from w w w .j ava2s. co m*/ //System.out.println(localName); while (iter.hasNext()) { Element e = iter.next(); if (e.matches(localName, atts)) { if (best == null || e.isBetterThan(best)) best = e; } } // use longest match if (best != null) { HTMLPattern hp = map.get(best); body.append(hp.getStartTag(atts)); stack.push(hp); current = hp; } else ignore.add(localName); }
From source file:com.swcguild.dvdlibraryarch.dao.DvdListDaoDbImpl.java
@Override public List<Dvd> searchDvds(Map<SearchTerm, String> criteria) { if (criteria.size() == 0) { return getAllDvds(); } else {/*from w ww . j a v a2 s.co m*/ StringBuilder sQuery = new StringBuilder("select * from dvds where "); // build the where clause int numParams = criteria.size(); int paramPosition = 0; String[] paramVals = new String[numParams]; Set<SearchTerm> keySet = criteria.keySet(); Iterator<SearchTerm> iter = keySet.iterator(); while (iter.hasNext()) { SearchTerm currentKey = iter.next(); if (paramPosition > 0) { sQuery.append(" and "); } sQuery.append(currentKey); sQuery.append(" = ? "); paramVals[paramPosition] = criteria.get(currentKey); paramPosition++; } return jdbcTemplate.query(sQuery.toString(), new DvdMapper(), paramVals); } }
From source file:org.lamop.riche.services.AuthorServiceImpl.java
@Transactional @Override//ww w . j av a 2 s.c om public void removeEntity(Long id) { Person p = getEntity(id); //Pour viter de recrer la relation par cascade , il faut modifier manuellement les sources Set<RelationSourcePerson> list = p.getRelationSource(); for (Iterator<RelationSourcePerson> iterator = list.iterator(); iterator.hasNext();) { RelationSourcePerson get = iterator.next(); // } // for (int i = 0; i < list.size(); i++) { // RelationSourcePerson get = list.get(i); Source s = get.getSource(); s.removeRelationPerson(get); daoSource.update(s); } dao.removeEntity(p); }