List of usage examples for java.util SortedSet size
int size();
From source file:org.jasig.schedassist.impl.owner.SpringJDBCAvailableScheduleDaoImpl.java
/** * Deletes all existing stored blocks and inserts all specified blocks. * /*from w ww. j a v a 2 s . c o m*/ * @param owner * @param blocks */ private void replaceSchedule(final IScheduleOwner owner, final SortedSet<AvailableBlock> blocks) { LOG.debug("replacing schedule for owner " + owner + "; argument contains " + blocks.size() + " blocks"); // delete all old blocks int rowsUpdated = this.simpleJdbcTemplate.update("delete from schedules where owner_id = ?", owner.getId()); LOG.debug("deleted " + rowsUpdated + " for owner " + owner.getId()); // persist the recombined set SortedSet<AvailableBlock> combined = AvailableBlockBuilder.combine(blocks); LOG.debug("combined set for owner contains " + combined.size() + " blocks"); Set<PersistenceAvailableBlock> persistenceBlocks = new HashSet<PersistenceAvailableBlock>(); for (AvailableBlock newBlock : combined) { PersistenceAvailableBlock p = new PersistenceAvailableBlock(newBlock, owner.getId()); persistenceBlocks.add(p); } internalStoreBlocks(persistenceBlocks); LOG.warn("schedule replaced for owner " + owner); if (null != applicationEventPublisher) { AvailableScheduleChangedEvent e = new AvailableScheduleChangedEvent(new AvailableSchedule(blocks), owner); applicationEventPublisher.publishEvent(e); } }
From source file:io.selendroid.common.SelendroidCapabilities.java
private String getDefaultVersion(Set<String> keys, String appName) { SortedSet<String> listOfApps = new TreeSet<String>(); for (String key : keys) { if (key.split(":")[0].contentEquals(appName)) { listOfApps.add(key);/*from w w w.ja va 2 s . c o m*/ } } return listOfApps.size() > 0 ? listOfApps.last() : null; }
From source file:net.sf.groovyMonkey.actions.RecreateMonkeyMenuAction.java
private void createTheMenu(final List<Association> menuData, final IAction action) { final MenuManager outerManager = ((WorkbenchWindow) window).getMenuManager(); if (outerManager == null) return;/*from w w w .ja v a 2s .com*/ final String menuName = getDefault().getPreferenceStore().getString(MONKEY_MENU_NAME); final IMenuManager menuManager = new MenuManager(menuName, MENU_PATH); outerManager.replaceItem(MENU_PATH, menuManager); final MonkeyMenuStruct current = new MonkeyMenuStruct(); current.key = ""; current.menu = menuManager; current.submenu = new MonkeyMenuStruct(); final SortedSet<Association> sorted = new TreeSet<Association>(); sorted.addAll(menuData); for (final Association association : sorted) addNestedMenuAction(current, association.key, association.file); final IWorkbenchWindow _window = window; if (sorted.size() != 0) menuManager.add(new Separator()); menuManager.add(new Action("Create New Script") { @Override public void run() { final IWorkbenchWindowActionDelegate delegate = new NewGroovyMonkeyScriptAction(); delegate.init(_window); delegate.run(action); } }); menuManager.add(new Action("Paste New Script") { @Override public void run() { final IWorkbenchWindowActionDelegate delegate = new PasteScriptFromClipboardAction(); delegate.init(_window); delegate.run(action); } }); menuManager.add(new Action("Pull scripts from URL") { @Override public void run() { final IWorkbenchWindowActionDelegate delegate = new PasteScriptsFromURL(); delegate.init(_window); delegate.run(action); } }); if (sorted.size() == 0) menuManager.add(new Action("Examples") { @Override public void run() { final IWorkbenchWindowActionDelegate delegate = new CreateGroovyMonkeyExamplesAction(); delegate.init(_window); delegate.run(action); } }); final IMenuManager editMenu = menuManager.findMenuUsingPath(MENU_EDIT_PATH) != null ? menuManager.findMenuUsingPath(MENU_EDIT_PATH) : new MenuManager("Edit Script", MENU_EDIT_PATH); menuManager.add(editMenu); current.key = ""; current.menu = editMenu; current.submenu = new MonkeyMenuStruct(); for (final Association association : sorted) addNestedMenuEditAction(current, association.key, association.file); outerManager.updateAll(true); }
From source file:org.mitre.mpf.wfm.data.entities.transients.Track.java
protected int compareDetections(SortedSet<Detection> a, SortedSet<Detection> b) { if (a == null && b == null) { return 0; } else if (a == null) { return 1; } else if (b == null) { return -1; } else {//from www .j a v a 2 s. co m int comparisonResult = 0; comparisonResult = Integer.compare(a.size(), b.size()); Iterator<Detection> firstIterator = a.iterator(); Iterator<Detection> secondIterator = b.iterator(); while ((comparisonResult == 0 && firstIterator.hasNext() && secondIterator.hasNext())) { Detection first = firstIterator.next(); Detection second = secondIterator.next(); if (first == null && second == null) { comparisonResult = 0; } else if (first == null) { comparisonResult = -1; // null < non-null } else if (second == null) { comparisonResult = 1; } else { comparisonResult = first.compareTo(second); } } return comparisonResult; } }
From source file:org.apache.ode.utils.fs.TempFileManager.java
@SuppressWarnings("unchecked") private synchronized void _cleanup() { try {//w w w . ja va 2 s. c om // collect all subdirectory contents that still exist, ordered files-first SortedSet<File> allFiles = new TreeSet(Collections.reverseOrder(null)); for (File f : _registeredFiles) { if (f.exists()) { allFiles.addAll(FileUtils.directoryEntriesInPath(f)); } } if (__log.isDebugEnabled()) { __log.debug("cleaning up " + allFiles.size() + " files."); } // now delete all files for (File f : allFiles) { if (__log.isDebugEnabled()) { __log.debug("deleting: " + f.getAbsolutePath()); } if (f.exists() && !f.delete()) { __log.error("Unable to delete file " + f.getAbsolutePath() + "; this may be caused by a descriptor leak and should be reported."); // fall back to deletion on VM shutdown f.deleteOnExit(); } } } finally { _registeredFiles.clear(); __workDir = null; __log.debug("cleanup done."); } }
From source file:com.spotify.heroic.filter.impl.OrFilterImpl.java
private static Filter optimize(SortedSet<Filter> statements) { final SortedSet<Filter> result = new TreeSet<>(); root: for (final Filter f : statements) { if (f instanceof Filter.Not) { final Filter.Not not = (Filter.Not) f; if (statements.contains(not.first())) { return TrueFilterImpl.get(); }//from www. j av a2 s.c o m result.add(f); continue; } if (f instanceof Filter.StartsWith) { final Filter.StartsWith outer = (Filter.StartsWith) f; for (final Filter inner : statements) { if (inner.equals(outer)) { continue; } if (inner instanceof Filter.StartsWith) { final Filter.StartsWith starts = (Filter.StartsWith) inner; if (!outer.first().equals(starts.first())) { continue; } if (FilterComparatorUtils.prefixedWith(outer.second(), starts.second())) { continue root; } } } result.add(f); continue; } // all ok! result.add(f); } if (result.isEmpty()) { return TrueFilterImpl.get(); } if (result.size() == 1) { return result.iterator().next(); } return new OrFilterImpl(new ArrayList<>(result)); }
From source file:com.restfb.util.InsightUtilsTest.java
@Test public void convertToMidnightInPacificTimeZoneSet1() throws ParseException { Date d20030630_0221utc = sdfUTC.parse("20030630_0221"); Date d20030629_0000pst = sdfPST.parse("20030629_0000"); Date d20030630_1503utc = sdfUTC.parse("20030630_1503"); Date d20030630_0000pst = sdfPST.parse("20030630_0000"); Set<Date> inputs = new HashSet<Date>(); inputs.add(d20030630_0221utc);/* w w w .j av a 2 s. c om*/ inputs.add(d20030630_1503utc); SortedSet<Date> actuals = convertToMidnightInPacificTimeZone(inputs); assertEquals(2, actuals.size()); Iterator<Date> it = actuals.iterator(); assertEquals(d20030629_0000pst, it.next()); assertEquals(d20030630_0000pst, it.next()); }
From source file:org.apache.accumulo.examples.wikisearch.ingest.WikipediaIngester.java
@Override public int run(String[] args) throws Exception { Job job = new Job(getConf(), "Ingest Wikipedia"); Configuration conf = job.getConfiguration(); conf.set("mapred.map.tasks.speculative.execution", "false"); String tablename = WikipediaConfiguration.getTableName(conf); String zookeepers = WikipediaConfiguration.getZookeepers(conf); String instanceName = WikipediaConfiguration.getInstanceName(conf); String user = WikipediaConfiguration.getUser(conf); byte[] password = WikipediaConfiguration.getPassword(conf); Connector connector = WikipediaConfiguration.getConnector(conf); TableOperations tops = connector.tableOperations(); createTables(tops, tablename, true); configureJob(job);//from w w w .j a va 2 s . c o m List<Path> inputPaths = new ArrayList<Path>(); SortedSet<String> languages = new TreeSet<String>(); FileSystem fs = FileSystem.get(conf); Path parent = new Path(conf.get("wikipedia.input")); listFiles(parent, fs, inputPaths, languages); System.out.println("Input files in " + parent + ":" + inputPaths.size()); Path[] inputPathsArray = new Path[inputPaths.size()]; inputPaths.toArray(inputPathsArray); System.out.println("Languages:" + languages.size()); FileInputFormat.setInputPaths(job, inputPathsArray); job.setMapperClass(WikipediaMapper.class); job.setNumReduceTasks(0); job.setMapOutputKeyClass(Text.class); job.setMapOutputValueClass(Mutation.class); job.setOutputFormatClass(AccumuloOutputFormat.class); AccumuloOutputFormat.setOutputInfo(job.getConfiguration(), user, password, true, tablename); AccumuloOutputFormat.setZooKeeperInstance(job.getConfiguration(), instanceName, zookeepers); return job.waitForCompletion(true) ? 0 : 1; }
From source file:org.codehaus.mojo.license.LicenseMap.java
public SortedSet<MavenProject> getUnsafeDependencies() { Log log = getLog();//from w w w .j av a2 s . co m // get unsafe dependencies (says with no license) SortedSet<MavenProject> unsafeDependencies = get(getUnknownLicenseMessage()); if (log.isDebugEnabled()) { if (CollectionUtils.isEmpty(unsafeDependencies)) { log.debug("There is no dependency with no license from poms."); } else { log.debug("There is " + unsafeDependencies.size() + " dependencies with no license from poms : "); for (MavenProject dep : unsafeDependencies) { // no license found for the dependency log.debug(" - " + ArtifactHelper.getArtifactId(dep.getArtifact())); } } } return unsafeDependencies; }
From source file:module.workingCapital.presentationTier.action.WorkingCapitalAction.java
private ActionForward showList(final HttpServletRequest request, final WorkingCapitalContext workingCapitalContext, final SortedSet<WorkingCapitalProcess> unitProcesses) { if (unitProcesses.size() == 1) { final WorkingCapitalProcess workingCapitalProcess = unitProcesses.first(); return ProcessManagement.forwardToProcess(workingCapitalProcess); } else {/*from ww w . jav a 2s . com*/ final List<WorkingCapitalProcess> list = new ArrayList<WorkingCapitalProcess>(unitProcesses); final String sortByArg = request.getParameter("sortBy"); if (sortByArg != null && !sortByArg.isEmpty()) { final int i = sortByArg.indexOf('='); if (i > 0) { final BeanComparator comparator = new BeanComparator(sortByArg.substring(0, i)); Collections.sort(list, comparator); final char c = sortByArg.charAt(i + 1); if (c == 'd' || c == 'D') { Collections.reverse(list); } } } request.setAttribute("unitProcesses", list); return frontPage(request, workingCapitalContext); } }