List of usage examples for java.util TreeSet add
public boolean add(E e)
From source file:com.qpark.maven.plugin.flowmapper.AbstractMappingOperationGenerator.java
protected String getMapperDefinitionSetter(final List<Entry<ComplexTypeChild, List<ComplexTypeChild>>> children, final Set<String> importedClasses) { StringBuffer sb = new StringBuffer(1024); ComplexContent cc = null;//from ww w .j av a 2 s.c o m TreeSet<String> usedInterfaces = new TreeSet<String>(); for (Entry<ComplexTypeChild, List<ComplexTypeChild>> child : children) { for (ComplexTypeChild grandchild : child.getValue()) { cc = this.getMapperDefinition(grandchild.getComplexType()); if (cc != null && !usedInterfaces.contains(cc.getFQInterfaceName())) { usedInterfaces.add(cc.getFQInterfaceName()); String varName = Util.lowerize(cc.interfaceClassName); String className = cc.interfaceClassName; if (!importedClasses.contains(cc.getFQInterfaceName())) { className = cc.getFQInterfaceName(); } sb.append("\t/**\n\t * Set the {@link "); sb.append(className); sb.append("}.\n\t * @param "); sb.append(varName); sb.append(" the {@ link "); sb.append(className); sb.append("}.\n\t */\n "); sb.append("\tpublic void set"); sb.append(cc.interfaceClassName); sb.append("("); sb.append(className); sb.append(" "); sb.append(varName); sb.append(") {\n\t\tthis."); sb.append(varName); sb.append(" = "); sb.append(varName); sb.append(";\n\t}\n\n"); } } } return sb.toString(); }
From source file:com.b2international.index.SortIndexTest.java
@Test public void sortFloatField() throws Exception { final PrimitiveIterator.OfDouble doubleIterator = new Random().doubles().iterator(); final TreeSet<Float> orderedItems = newTreeSet(); final Map<String, Data> documents = newHashMap(); for (int i = 0; i < NUM_DOCS; i++) { float item = 0.0f; while (item == 0.0f || orderedItems.contains(item)) { item = (float) doubleIterator.nextDouble(); }// w ww. j a v a 2 s . c o m orderedItems.add(item); final Data data = new Data(); data.setFloatField(item); documents.put(Integer.toString(i), data); } indexDocuments(documents); final Query<Data> ascendingQuery = Query.select(Data.class).where(Expressions.matchAll()).limit(NUM_DOCS) .sortBy(SortBy.field("floatField", Order.ASC)).build(); checkDocumentOrder(ascendingQuery, data -> data.getFloatField(), orderedItems, Float.class); final Query<Data> descendingQuery = Query.select(Data.class).where(Expressions.matchAll()).limit(NUM_DOCS) .sortBy(SortBy.field("floatField", Order.DESC)).build(); checkDocumentOrder(descendingQuery, data -> data.getFloatField(), orderedItems.descendingSet(), Float.class); }
From source file:com.b2international.index.SortIndexTest.java
@Test public void sortStringField() throws Exception { final TreeSet<String> orderedItems = newTreeSet(); final Map<String, Data> documents = newHashMap(); for (int i = 0; i < NUM_DOCS; i++) { String item = null;/*from ww w . j a v a 2 s .com*/ while (item == null || orderedItems.contains(item)) { item = RandomStringUtils.randomAlphabetic(10); } orderedItems.add(item); final Data data = new Data(); data.setField1(item); documents.put(Integer.toString(i), data); } indexDocuments(documents); final Query<Data> ascendingQuery = Query.select(Data.class).where(Expressions.matchAll()).limit(NUM_DOCS) .sortBy(SortBy.field("field1", Order.ASC)).build(); checkDocumentOrder(ascendingQuery, data -> data.getField1(), orderedItems, String.class); final Query<Data> descendingQuery = Query.select(Data.class).where(Expressions.matchAll()).limit(NUM_DOCS) .sortBy(SortBy.field("field1", Order.DESC)).build(); checkDocumentOrder(descendingQuery, data -> data.getField1(), orderedItems.descendingSet(), String.class); }
From source file:com.b2international.index.SortIndexTest.java
@Test public void sortAnalyzedField() throws Exception { final TreeSet<String> orderedItems = newTreeSet(); final Map<String, Data> documents = newHashMap(); for (int i = 0; i < NUM_DOCS; i++) { String item = null;//from w w w . j a va 2 s .c o m while (item == null || orderedItems.contains(item)) { item = RandomStringUtils.randomAlphabetic(10); } orderedItems.add(item); final Data data = new Data(); data.setAnalyzedField(item); documents.put(Integer.toString(i), data); } indexDocuments(documents); final Query<Data> ascendingQuery = Query.select(Data.class).where(Expressions.matchAll()).limit(NUM_DOCS) .sortBy(SortBy.field("analyzedField.exact", Order.ASC)).build(); checkDocumentOrder(ascendingQuery, data -> data.getAnalyzedField(), orderedItems, String.class); final Query<Data> descendingQuery = Query.select(Data.class).where(Expressions.matchAll()).limit(NUM_DOCS) .sortBy(SortBy.field("analyzedField.exact", Order.DESC)).build(); checkDocumentOrder(descendingQuery, data -> data.getAnalyzedField(), orderedItems.descendingSet(), String.class); }
From source file:net.spfbl.core.Peer.java
public static TreeSet<Peer> getReputationSet() { TreeSet<Peer> peerSet = new TreeSet<Peer>(); for (Peer peer : getSet()) { switch (peer.getSendStatus()) { case BLOCK: case REPUTATION: case ALWAYS: case REPASS: case MIRROR: peerSet.add(peer); break; }//from w w w. j a v a 2s . c o m } return peerSet; }
From source file:com.antelink.sourcesquare.client.scan.SourceSquareFSWalker.java
private TreemapNode reccursiveIdentifyFiles(File directory, TreeSet<File> fileSet, int depth) { if (this.levels.size() < depth + 1) { this.levels.add(0); }// w ww. j av a 2s .c o m logger.trace("Counting going down to directory : " + directory.getAbsolutePath()); if (directory.isHidden()) { this.eventBus.fireEvent(new HiddenFileFoundEvent(directory)); return null; } if (directory.isFile()) { fileSet.add(directory); return null; } if (!directory.isDirectory()) { return null; } // Protection if the directory forbids listing if (directory.listFiles() == null) { return null; } Set<TreemapNode> children = new HashSet<TreemapNode>(); int nbFiles = 0; int nbDirs = 0; for (File child : directory.listFiles()) { if (child.isDirectory() || !child.isHidden()) { if (child.isDirectory()) { nbDirs++; TreemapNode childNode = reccursiveIdentifyFiles(child, fileSet, depth + 1); if (childNode != null) { children.add(childNode); } } else if (child.isFile()) { nbFiles++; fileSet.add(child); } } } this.total = this.total + nbFiles; ScanStatus.INSTANCE.setNbFilesToScan((int) this.total); this.levels.set(depth, this.levels.get(depth) + nbDirs); return this.treemap.createTreeMapNode(directory.getAbsolutePath(), children, nbFiles); }
From source file:com.google.enterprise.connector.persist.MigrateStore.java
/** * Returns a Collection of the names of configured, but not disabled, * PersistentStores./* ww w. j av a 2s. c o m*/ */ @SuppressWarnings("unchecked") private Collection<String> getStoreNames() { TreeSet<String> names = new TreeSet<String>(); Map<String, PersistentStore> stores = (Map<String, PersistentStore>) Context.getInstance() .getApplicationContext().getBeansOfType(PersistentStore.class); for (Map.Entry<String, PersistentStore> entry : stores.entrySet()) { // Only include PersistentStores that are not disabled. if (!entry.getValue().isDisabled()) { names.add(entry.getKey()); } } return names; }
From source file:edu.wustl.mir.erl.ihe.xdsi.util.DICOMUtility.java
public KOSBean manufactureKOSFromUIDs(List<String> uidList, String retrieveAETitle, String retrieveLocationUID, String classUID) throws Exception { KOSBean bean = new KOSBean(null); Iterator<String> it = uidList.iterator(); HashMap<String, TreeSet<String>> studySeriesMap = new HashMap<String, TreeSet<String>>(); HashMap<String, TreeSet<String>> seriesInstanceMap = new HashMap<String, TreeSet<String>>(); while (it.hasNext()) { String composite = it.next(); String[] tokens = composite.split(":"); String studyUID = tokens[0]; String seriesUID = tokens[1]; String instanceUID = tokens[2]; if (studySeriesMap.containsKey(studyUID)) { TreeSet<String> x = studySeriesMap.get(studyUID); x.add(seriesUID); } else {//from w w w . j a v a 2 s . c o m TreeSet<String> x = new TreeSet<String>(); x.add(seriesUID); studySeriesMap.put(studyUID, x); } if (seriesInstanceMap.containsKey(seriesUID)) { TreeSet<String> y = seriesInstanceMap.get(seriesUID); y.add(instanceUID); } else { TreeSet<String> y = new TreeSet<String>(); y.add(instanceUID); seriesInstanceMap.put(seriesUID, y); } } Iterator<String> itStudy = studySeriesMap.keySet().iterator(); while (itStudy.hasNext()) { String studyUID = itStudy.next(); KOSStudyBean studyBean = new KOSStudyBean(studyUID, null); TreeSet<String> seriesSet = studySeriesMap.get(studyUID); Iterator<String> itSeries = seriesSet.iterator(); while (itSeries.hasNext()) { String seriesUID = itSeries.next(); KOSSeriesBean seriesBean = new KOSSeriesBean(seriesUID, retrieveAETitle, retrieveLocationUID, null); TreeSet<String> instanceSet = seriesInstanceMap.get(seriesUID); Iterator<String> itInstance = instanceSet.iterator(); while (itInstance.hasNext()) { String instanceUID = itInstance.next(); KOSInstanceBean instanceBean = new KOSInstanceBean(instanceUID, classUID); seriesBean.addInstanceBean(instanceBean); } studyBean.addSeriesBean(seriesBean); } bean.addStudyBean(studyBean); } return bean; }
From source file:edu.wustl.mir.erl.ihe.xdsi.util.DICOMUtility.java
public KOSBean manufactureKOSFromUIDs(KOSBean bean, List<String> uidList, String retrieveAETitle, String retrieveLocationUID, String classUID) throws Exception { HashMap<String, TreeSet<String>> studySeriesMap = new HashMap<String, TreeSet<String>>(); HashMap<String, TreeSet<String>> seriesInstanceMap = new HashMap<String, TreeSet<String>>(); if (bean == null) { bean = new KOSBean(null); }/* ww w . ja v a 2 s . c om*/ Iterator<String> it = uidList.iterator(); while (it.hasNext()) { String composite = it.next(); String[] tokens = composite.split(":"); String studyUID = tokens[0]; String seriesUID = tokens[1]; String instanceUID = tokens[2]; if (studySeriesMap.containsKey(studyUID)) { TreeSet<String> x = studySeriesMap.get(studyUID); x.add(seriesUID); } else { TreeSet<String> x = new TreeSet<String>(); x.add(seriesUID); studySeriesMap.put(studyUID, x); } if (seriesInstanceMap.containsKey(seriesUID)) { TreeSet<String> y = seriesInstanceMap.get(seriesUID); y.add(instanceUID); } else { TreeSet<String> y = new TreeSet<String>(); y.add(instanceUID); seriesInstanceMap.put(seriesUID, y); } } Iterator<String> itStudy = studySeriesMap.keySet().iterator(); while (itStudy.hasNext()) { String studyUID = itStudy.next(); KOSStudyBean studyBean = new KOSStudyBean(studyUID, null); TreeSet<String> seriesSet = studySeriesMap.get(studyUID); Iterator<String> itSeries = seriesSet.iterator(); while (itSeries.hasNext()) { String seriesUID = itSeries.next(); KOSSeriesBean seriesBean = new KOSSeriesBean(seriesUID, retrieveAETitle, retrieveLocationUID, null); TreeSet<String> instanceSet = seriesInstanceMap.get(seriesUID); Iterator<String> itInstance = instanceSet.iterator(); while (itInstance.hasNext()) { String instanceUID = itInstance.next(); KOSInstanceBean instanceBean = new KOSInstanceBean(instanceUID, classUID); seriesBean.addInstanceBean(instanceBean); } studyBean.addSeriesBean(seriesBean); } bean.addStudyBean(studyBean); } return bean; }
From source file:com.b2international.index.SortIndexTest.java
@Test public void sortBigDecimalField() throws Exception { final PrimitiveIterator.OfDouble doubleIterator = new Random().doubles().iterator(); final TreeSet<BigDecimal> orderedItems = newTreeSet(); final Map<String, Data> documents = newHashMap(); for (int i = 0; i < NUM_DOCS; i++) { BigDecimal item = null;//from w ww. j a va2 s .co m while (item == null || orderedItems.contains(item)) { item = BigDecimal.valueOf(doubleIterator.nextDouble()); } orderedItems.add(item); final Data data = new Data(); data.setBigDecimalField(item); documents.put(Integer.toString(i), data); } indexDocuments(documents); final Query<Data> ascendingQuery = Query.select(Data.class).where(Expressions.matchAll()).limit(NUM_DOCS) .sortBy(SortBy.field("bigDecimalField", Order.ASC)).build(); checkDocumentOrder(ascendingQuery, data -> data.getBigDecimalField(), orderedItems, BigDecimal.class); final Query<Data> descendingQuery = Query.select(Data.class).where(Expressions.matchAll()).limit(NUM_DOCS) .sortBy(SortBy.field("bigDecimalField", Order.DESC)).build(); checkDocumentOrder(descendingQuery, data -> data.getBigDecimalField(), orderedItems.descendingSet(), BigDecimal.class); }