List of usage examples for java.util TreeSet TreeSet
public TreeSet(SortedSet<E> s)
From source file:com.github.drbookings.LocalDates.java
public static Range<LocalDate> getDateRange(final Collection<? extends LocalDate> dates, final boolean oneMoreAtTheBeginning) { final TreeSet<LocalDate> set = new TreeSet<>(dates); if (set.isEmpty()) { return null; }/*from w w w .ja v a 2s. c om*/ final LocalDate d1; final LocalDate d2; d2 = set.last(); if (oneMoreAtTheBeginning) { d1 = set.first().minusDays(1); } else { d1 = set.first(); } return Range.closed(d1, d2); }
From source file:mx.ecosur.multigame.gente.event.MoveEvent.java
public MoveEvent() { origin = null; adjacentCells = new TreeSet<GridCell>(new CellComparator()); direction = Direction.UNKNOWN; }
From source file:cn.edu.zjnu.acm.judge.config.LocaleFactory.java
public LocaleFactory() { Collection<String> set = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); set.addAll(Arrays.asList("en", "zh")); this.allLanguages = set; }
From source file:com.zimbra.cs.account.PreAuthKey.java
public static String computePreAuth(Map<String, String> params, String key) { TreeSet<String> names = new TreeSet<String>(params.keySet()); StringBuilder sb = new StringBuilder(); for (String name : names) { if (sb.length() > 0) sb.append('|'); sb.append(params.get(name));/*from ww w. j a v a 2 s . co m*/ } return getHmac(sb.toString(), key.getBytes()); }
From source file:com.espertech.esper.filter.TestStringRangeComparator.java
public void testComparator() { SortedSet<StringRange> sorted = new TreeSet<StringRange>(new StringRangeComparator()); final String[][] TEST_SET = { { "B", "G" }, { "B", "F" }, { null, "E" }, { "A", "F" }, { "A", "G" }, }; final int[] EXPECTED_INDEX = { 2, 3, 4, 1, 0 }; // Sort// www. j a v a 2s. c o m StringRange ranges[] = new StringRange[TEST_SET.length]; for (int i = 0; i < TEST_SET.length; i++) { ranges[i] = new StringRange(TEST_SET[i][0], TEST_SET[i][1]); sorted.add(ranges[i]); } System.out.println("sorted=" + sorted); // Check results int count = 0; for (Iterator<StringRange> i = sorted.iterator(); i.hasNext();) { StringRange range = i.next(); int indexExpected = EXPECTED_INDEX[count]; StringRange expected = ranges[indexExpected]; log.debug(".testComparator count=" + count + " range=" + range + " expected=" + expected); assertEquals("failed at count " + count, range, expected); count++; } assertEquals(count, TEST_SET.length); }
From source file:com.espertech.esper.filter.TestDoubleRangeComparator.java
public void testComparator() { SortedSet<DoubleRange> sorted = new TreeSet<DoubleRange>(new DoubleRangeComparator()); final double[][] TEST_SET = { { 10, 20 }, // 4 { 10, 15 }, // 2 { 10, 25 }, // 5 { 5, 20 }, // 0 { 5, 25 }, // 1 { 15, 20 }, // 6 { 10, 16 } }; // 3 final int[] EXPECTED_INDEX = { 3, 4, 1, 6, 0, 2, 5 }; // Sort//w ww. j a va 2s .c o m DoubleRange ranges[] = new DoubleRange[TEST_SET.length]; for (int i = 0; i < TEST_SET.length; i++) { ranges[i] = new DoubleRange(TEST_SET[i][0], TEST_SET[i][1]); sorted.add(ranges[i]); } // Check results int count = 0; for (Iterator<DoubleRange> i = sorted.iterator(); i.hasNext();) { DoubleRange range = i.next(); int indexExpected = EXPECTED_INDEX[count]; DoubleRange expected = ranges[indexExpected]; log.debug(".testComparator count=" + count + " range=" + range + " expected=" + expected); assertEquals(range, expected); count++; } assertEquals(count, TEST_SET.length); }
From source file:com.pc.dailymile.domain.Routes.java
public Set<Route> getRoutes() { if (routes == null) { return Collections.emptySet(); }//ww w . ja v a 2 s. c o m return new TreeSet<Route>(routes); }
From source file:com.rapleaf.hank.coordinator.Domains.java
public static DomainVersion getLatestVersionNotOpenNotDefunct(Domain domain) throws IOException { Set<DomainVersion> originalVersions = domain.getVersions(); if (originalVersions == null || originalVersions.size() == 0) { return null; }/*from w w w . ja va2 s .c o m*/ SortedSet<DomainVersion> versions = new TreeSet<DomainVersion>(new ReverseComparator<DomainVersion>()); versions.addAll(originalVersions); for (DomainVersion version : versions) { if (DomainVersions.isClosed(version) && !version.isDefunct()) { return version; } } return null; }
From source file:com.vrem.wifianalyzer.wifi.band.WiFiChannelCountryGHZ5.java
WiFiChannelCountryGHZ5() { SortedSet<Integer> channelsSet1 = new TreeSet<>(Arrays.asList(36, 40, 44, 48, 52, 56, 60, 64)); SortedSet<Integer> channelsSet2 = new TreeSet<>( Arrays.asList(100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140, 144)); SortedSet<Integer> channelsSet3 = new TreeSet<>(Arrays.asList(149, 153, 157, 161, 165)); SortedSet<Integer> channelsToExcludeCanada = new TreeSet<>(Arrays.asList(120, 124, 128)); SortedSet<Integer> channelsToExcludeIsrael = new TreeSet<>(channelsSet2); channelsToExcludeIsrael.addAll(channelsSet3); channelsToExclude = new HashMap<>(); channelsToExclude.put("AU", channelsToExcludeCanada); // Australia channelsToExclude.put("CA", channelsToExcludeCanada); // Canada channelsToExclude.put("CN", channelsSet2); // China channelsToExclude.put("IL", channelsToExcludeIsrael); // Israel channelsToExclude.put("JP", channelsSet3); // Japan channelsToExclude.put("KR", channelsSet2); // South Korea channelsToExclude.put("TR", channelsSet3); // Turkey channelsToExclude.put("ZA", channelsSet3); // South Africa channels = new TreeSet<>(channelsSet1); channels.addAll(channelsSet2);/*from w ww.j a v a 2 s . c o m*/ channels.addAll(channelsSet3); }
From source file:com.github.pjungermann.config.errors.KeysWithoutSpecificationError.java
public KeysWithoutSpecificationError(@NotNull final Collection<String> keys) { this.keys = new TreeSet<>(keys); }