List of usage examples for java.util TreeSet size
public int size()
From source file:org.apache.shindig.common.util.StringEncoding.java
/** Creates a new encoding based on the supplied set of digits. */ public StringEncoding(final char[] userDigits) { TreeSet<Character> t = Sets.newTreeSet(); for (char c : userDigits) { t.add(c);/*from w w w.j a va 2 s. c o m*/ } char[] digits = new char[t.size()]; int i = 0; for (char c : t) { digits[i++] = c; } this.DIGITS = digits; this.MASK = digits.length - 1; this.SHIFT = Integer.numberOfTrailingZeros(MASK + 1); if ((MASK + 1) != (1 << SHIFT) || digits.length >= 256) { throw new AssertionError(Arrays.toString(digits)); } }
From source file:com.antelink.sourcesquare.client.scan.ScanStatusManager.java
public void bind() { this.eventbus.addHandler(FilesIdentifiedEvent.TYPE, new FilesIdentifiedEventHandler() { @Override//ww w. j a v a 2 s . c o m public String getId() { return getClass().getCanonicalName() + ": " + StartScanEventHandler.class.getName(); } @Override public void handle(TreeSet<File> fileSet) { ScanStatus.INSTANCE.setNbFilesToScan(fileSet.size()); ScanStatus.INSTANCE.setQuerying(); } }); this.eventbus.addHandler(ScanCompleteEvent.TYPE, new ScanCompleteEventHandler() { @Override public String getId() { return getClass().getCanonicalName() + ": " + ScanCompleteEventHandler.class.getName(); } @Override public void handle(ArrayList<Integer> levels) { logger.info("Scan finished, processing results..."); ScanStatus.INSTANCE.setProcessing(); } }); this.eventbus.addHandler(FilesScannedEvent.TYPE, new FilesScannedEventHandler() { @Override public String getId() { return getClass().getCanonicalName() + ": " + FilesScannedEventHandler.class.getName(); } @Override public void handle(int count) { ScanStatus.INSTANCE.addFilesScanned(count); long averageTime = ScanStatusManager.this.computeAverageTime(); ScanStatus.INSTANCE.setAverageScanningTime(averageTime); ScanStatus.INSTANCE.setLastUpdateTime(new Date().getTime()); logger.info("Finish scan for " + count + " files, average scanning time: " + averageTime + " ms"); } }); this.eventbus.addHandler(OSFilesFoundEvent.TYPE, new OSFilesFoundEventHandler() { @Override public String getId() { return getClass().getCanonicalName() + ": " + OSFilesFoundEventHandler.class.getName(); } @Override public void handle(Set<String> fileSet) { logger.info(fileSet.size() + " open source files found"); ScanStatus.INSTANCE.addOSFiles(fileSet.size()); } }); }
From source file:com.yahoo.rdfpig.optimizer.OnceDynamicOptimizationStrategy.java
@Override public Set<TupleExpr> selectPlans(TreeSet<SearchPath> candidates, SamplingCardinalityCalculator calculator) { HashSet<TupleExpr> ret = new HashSet<TupleExpr>(); double[] costs = new double[candidates.size()]; int i = 0;/*from w w w . j av a2 s.c o m*/ for (SearchPath p : candidates) costs[i++] = p.cost; double dev = stdDev.evaluate(costs); int plansPerSubgraph = (int) dev + 1; i = 0; for (SearchPath p : candidates) { if (!calculator.isCalculated(p.current) && !calculator.isSampled(p.current)) { ret.add(p.current); if (i++ > plansPerSubgraph) break; } } return ret; }
From source file:org.polymap.biotop.model.importer.MdbImportPage.java
public void uploadFinished(UploadEvent ev) { UploadItem item = upload.getUploadItem(); try {//from w w w. j a va 2s .c o m log.info("Uploaded: " + item.getFileName() + ", path=" + item.getFilePath()); File uploadDir = Polymap.getWorkspacePath().toFile(); dbFile = new File(uploadDir, item.getFileName()); FileOutputStream out = new FileOutputStream(dbFile); StreamUtils.copyThenClose(item.getFileInputStream(), out); log.info("### copied to: " + dbFile); Database db = Database.open(dbFile); log.info("Tables: " + db.getTableNames()); TreeSet<String> sorted = new TreeSet<String>(db.getTableNames()); tablesList.setItems(sorted.toArray(new String[sorted.size()])); db.close(); } catch (IOException e) { PolymapWorkbench.handleError(DataPlugin.PLUGIN_ID, MdbImportPage.this, "Fehler beim Upload der Daten.", e); } checkFinish(); }
From source file:com.chingo247.structureapi.commands.StructureCommands.java
private static String getInfo(StructureNode structure, IColors colors) { TreeSet<String> owners = Sets.newTreeSet(ALPHABETICAL_ORDER); List<SettlerNode> mastersNode = structure.getOwnerDomain().getOwners(OwnerType.MASTER); for (SettlerNode master : mastersNode) { owners.add(master.getName());/*from w ww . ja v a 2 s. co m*/ } String ownershipString = ""; int size = owners.size(); int count = 0; for (String ownership : owners) { ownershipString += colors.yellow() + ownership + colors.reset(); count++; if (count != size) { ownershipString += ", "; } } String line = "#" + colors.gold() + structure.getId() + " " + colors.blue() + structure.getName() + "\n" + colors.reset() + "World: " + colors.yellow() + structure.getWorldName() + "\n"; Vector position = structure.getOrigin(); line += colors.reset() + "Location: " + colors.yellow() + "X: " + colors.reset() + position.getX() + " " + colors.yellow() + "Y: " + colors.reset() + position.getY() + " " + colors.yellow() + "Z: " + colors.reset() + position.getZ() + "\n"; CuboidRegion region = structure.getCuboidRegion(); line += colors.reset() + "Width: " + colors.yellow() + region.getWidth() + colors.reset() + " Height: " + colors.yellow() + region.getHeight() + colors.reset() + " Length: " + colors.yellow() + region.getLength() + colors.reset() + "\n"; line += colors.reset() + "Status: " + colors.reset() + getStatusString(structure, colors) + "\n"; if (structure.getPrice() > 0) { line += colors.reset() + "Value: " + colors.yellow() + structure.getPrice() + "\n"; } if (!owners.isEmpty()) { if (owners.size() == 1) { line += colors.reset() + "Owners(MASTER): " + ownershipString + "\n"; } else { line += colors.reset() + "Owners(MASTER): \n" + ownershipString + "\n"; } } if (structure.getNode().hasProperty("WGRegion")) { line += colors.reset() + "WorldGuard-Region: " + colors.yellow() + structure.getNode().getProperty("WGRegion"); } return line; }
From source file:org.polymap.kaps.importer.MdbImportPage.java
public void uploadFinished(UploadEvent ev) { UploadItem item = upload.getUploadItem(); try {/* w w w. j a v a2 s . c om*/ log.info("Uploaded: " + item.getFileName() + ", path=" + item.getFilePath()); File uploadDir = Polymap.getWorkspacePath().toFile(); dbFile = new File(uploadDir, item.getFileName()); FileOutputStream out = new FileOutputStream(dbFile); StreamUtils.copyThenClose(item.getFileInputStream(), out); log.info("### copied to: " + dbFile); Database db = Database.open(dbFile); log.info("Tables: " + db.getTableNames()); TreeSet<String> sorted = new TreeSet<String>(db.getTableNames()); tablesList.setItems(sorted.toArray(new String[sorted.size()])); db.close(); } catch (IOException e) { PolymapWorkbench.handleError(DataPlugin.PLUGIN_ID, MdbImportPage.this, "Fehler beim Upload der Daten.", e); } checkFinish(); }
From source file:com.atolcd.pentaho.di.trans.steps.gisgeoprocessing.GisGeoprocessing.java
private static LineString[] splitLineStringAtCoordinates(Coordinate[] splitCoordinates, LineString inputLineString, double distance) { List<LineString> lineStrings = new ArrayList<LineString>(); LengthIndexedLine lengthIndexedLine = new LengthIndexedLine(inputLineString); TreeSet<Double> indexesTree = new TreeSet<Double>(); indexesTree.add(lengthIndexedLine.getStartIndex()); indexesTree.add(lengthIndexedLine.getEndIndex()); for (Coordinate splitCoordinate : splitCoordinates) { if (geometryFactory.createPoint(splitCoordinate).distance(inputLineString) <= distance) { indexesTree.add(lengthIndexedLine.project(splitCoordinate)); }//from ww w. ja va 2 s . c o m } Double[] indexes = indexesTree.toArray(new Double[indexesTree.size()]); for (int i = 0; i < indexes.length - 1; i++) { LineString splitedLineString = (LineString) lengthIndexedLine.extractLine(indexes[i], indexes[i + 1]); if (splitedLineString != null && !splitedLineString.isEmpty()) { lineStrings.add(splitedLineString); } } return lineStrings.toArray(new LineString[lineStrings.size()]); }
From source file:edu.uiowa.icts.bluebutton.json.view.EncountersMetaFinder.java
public String getOrganizations() { TreeSet<String> orgSet = new TreeSet<String>(); for (Encounter e : this.list) { if (e.getLocation() != null && e.getLocation().getOrganization() != null) { orgSet.add(e.getLocation().getOrganization()); }//w ww . j a v a 2s . co m } if (orgSet.size() > 0) { return StringUtils.join(orgSet, ", "); } return null; }
From source file:org.eclipse.skalli.view.component.PeopleSearchWindow.java
private void search(String searchText) { dataSource.removeAllItems();//w w w. jav a 2 s . c o m if (StringUtils.isNotEmpty(searchText)) { TreeSet<User> sorted = new TreeSet<User>(UserContainer.findUsers(searchText)); for (User user : sorted) { dataSource.addItem(user); } if (sorted.size() == 1) { list.select(sorted.iterator().next()); } } }
From source file:com.antelink.sourcesquare.client.scan.SourceSquareFSWalker.java
public void bind() { this.eventBus.addHandler(StartScanEvent.TYPE, new StartScanEventHandler() { @Override/*from w w w . j a v a 2s . c o m*/ public String getId() { return getClass().getCanonicalName() + ": " + StartScanEventHandler.class.getName(); } @Override public void handle(File toScan) { logger.info("Counting files..."); SourceSquareFSWalker.this.identifyFiles(toScan); } }); this.eventBus.addHandler(FilesIdentifiedEvent.TYPE, new FilesIdentifiedEventHandler() { @Override public String getId() { return getClass().getCanonicalName() + ": " + StartScanEventHandler.class.getName(); } @Override public void handle(TreeSet<File> fileSet) { try { logger.info("Start scan for " + fileSet.size() + " files"); ScanStatus.INSTANCE.start(); SourceSquareFSWalker.this.queryFiles(fileSet); } catch (Exception e) { logger.debug("Error handling tree identification", e); } } }); }