List of usage examples for java.util SortedSet iterator
Iterator<E> iterator();
From source file:com.migratebird.script.repository.impl.ArchiveScriptLocationMigrateBirdScriptsArchiveTest.java
private void assertEqualScripts(SortedSet<Script> originalScripts, SortedSet<Script> scriptsFromFile) throws IOException { Iterator<Script> scriptsFromFileIterator = scriptsFromFile.iterator(); for (Script originalScript : originalScripts) { assertEqualScripts(originalScript, scriptsFromFileIterator.next()); }/*from www .jav a 2 s.co m*/ }
From source file:org.apache.ctakes.ytex.kernel.dao.SortedSetUserType.java
private String sortedSetToString(SortedSet<String> set) { StringBuilder b = new StringBuilder(); Iterator<String> iter = set.iterator(); while (iter.hasNext()) { b.append(iter.next());/* w w w. java2s. c o m*/ if (iter.hasNext()) { b.append("|"); } } return b.toString(); }
From source file:com.spotify.heroic.filter.OrFilter.java
static Filter optimize(final SortedSet<Filter> filters) { final SortedSet<Filter> result = new TreeSet<>(); for (final Filter f : filters) { if (f instanceof NotFilter) { // Optimize away expressions which are always true. // Example: foo = bar or !(foo = bar) if (filters.contains(((NotFilter) f).getFilter())) { return TrueFilter.get(); }/* ww w.j a v a2 s .co m*/ } else if (f instanceof StartsWithFilter) { // Optimize away prefixes which encompass each other. // Example: foo ^ hello or foo ^ helloworld -> foo ^ hello if (FilterUtils.containsPrefixedWith(filters, (StartsWithFilter) f, (inner, outer) -> FilterUtils.prefixedWith(outer.getValue(), inner.getValue()))) { continue; } } result.add(f); } if (result.isEmpty()) { return TrueFilter.get(); } if (result.size() == 1) { return result.iterator().next(); } return new OrFilter(ImmutableList.copyOf(result)); }
From source file:com.opencredo.portlet.MyBooksController.java
private void storeMyBooks(PortletPreferences prefs, SortedSet<Book> myBooks) { ArrayList<String> keys = new ArrayList<String>(); for (Iterator<Book> i = myBooks.iterator(); i.hasNext();) { Book book = i.next();//from w w w .j a va2 s. c om keys.add(book.getKey().toString()); } String[] keysArr = keys.toArray(new String[] {}); try { prefs.setValues("myBooks", keysArr); prefs.store(); } catch (Exception e) { logger.warn("unable to set portlet preference", e); } }
From source file:com.liangc.hq.base.utils.BizappUtils.java
public static List sortAIResource(List resource) { List sortedList = new ArrayList(); SortedSet sSet = new TreeSet(new BizappUtils().new AIResourceIdComparator()); sSet.addAll(resource);//from ww w . jav a 2s . c o m CollectionUtils.addAll(sortedList, sSet.iterator()); return sortedList; }
From source file:org.apache.ctakes.ytex.kernel.dao.StringArrayUserType.java
private String stringArrayToString(String[] set) { StringBuilder b = new StringBuilder(); SortedSet<String> s = new TreeSet<String>(); s.addAll(Arrays.asList(set)); Iterator<String> iter = s.iterator(); while (iter.hasNext()) { b.append(iter.next());/*www . ja v a2 s. co m*/ if (iter.hasNext()) { b.append("|"); } } return b.toString(); }
From source file:sample.portlet.MyBooksEditController.java
private void storeMyBooks(PortletRequest request, SortedSet<Book> myBooks) { ArrayList<String> keys = new ArrayList<String>(); for (Iterator<Book> i = myBooks.iterator(); i.hasNext();) { Book book = i.next();/*from ww w . ja va 2 s . co m*/ keys.add(book.getKey().toString()); } String[] keysArr = keys.toArray(new String[] {}); try { PortletPreferences prefs = request.getPreferences(); prefs.setValues("myBooks", keysArr); prefs.store(); } catch (Exception e) { logger.warn("unable to set portlet preference", e); } }
From source file:com.liangc.hq.base.utils.BizappUtils.java
/** * This method sorts list of AppdefResourceValue objects * /*from w w w . j a va 2 s .c o m*/ * @return a list of AppdefResourceValue objects */ public static List<AppdefResourceValue> sortAppdefResource(List appdefList, PageControl pc) { List sortedList = new ArrayList(); SortedSet sSet = new TreeSet(new BizappUtils().new AppdefResourceNameComparator(pc)); sSet.addAll(appdefList); CollectionUtils.addAll(sortedList, sSet.iterator()); // There are duplicated names, figure out where to insert them for (Iterator it = appdefList.iterator(); sortedList.size() != appdefList.size() && it.hasNext();) { AppdefResourceValue res = (AppdefResourceValue) it.next(); for (int i = 0; i < sortedList.size(); i++) { AppdefResourceValue sorted = (AppdefResourceValue) sortedList.get(i); if (sorted.getEntityId().equals(res.getEntityId())) break; // Either it's meant to go in between or the last if (res.getName().toLowerCase().compareTo(sorted.getName().toLowerCase()) < 0 || i == sortedList.size() - 1) { sortedList.add(i, res); break; } } } return sortedList; }
From source file:edu.northwestern.bioinformatics.studycalendar.xml.writers.PeriodXmlSerializer.java
public Period getPeriodWithMatchingGridId(SortedSet<Period> periods, Element childElement) { for (Iterator<Period> iterator = periods.iterator(); iterator.hasNext();) { Period period = iterator.next(); if (StringUtils.equals(period.getGridId(), childElement.attributeValue(ID))) { return period; }/*from ww w .j a va2 s.c om*/ } return null; }
From source file:pl.otros.logview.gui.message.StackTraceFinderTest.java
@Test public void testFindForEmptyPackage() throws IOException { // given/*from ww w . j a v a 2s . c o m*/ String stacktraceFile = IOUtils.toString(StackTraceColorizer.class.getClassLoader() .getResourceAsStream("stacktrace/stacktTraceWtihEmptyPackage.txt")); // when SortedSet<SubText> findStackTraces = finder.findStackTraces(stacktraceFile); // then assertEquals(1, findStackTraces.size()); SubText subtext = findStackTraces.iterator().next(); assertEquals(0, subtext.start); assertEquals(213, subtext.end); }