Example usage for java.util TreeSet TreeSet

List of usage examples for java.util TreeSet TreeSet

Introduction

In this page you can find the example usage for java.util TreeSet TreeSet.

Prototype

public TreeSet(SortedSet<E> s) 

Source Link

Document

Constructs a new tree set containing the same elements and using the same ordering as the specified sorted set.

Usage

From source file:com.linkedin.pinot.common.restlet.PinotRestletApplication.java

protected void attachRoutesForClass(Router router, Class<? extends ServerResource> clazz) {
    TreeSet<String> pathsOrderedByLength = new TreeSet<String>(
            ComparatorUtils.chainedComparator(new Comparator<String>() {

                @Override/* ww w .  jav  a  2 s  .  c o m*/
                public int compare(String left, String right) {
                    int leftLength = left.length();
                    int rightLength = right.length();
                    return leftLength < rightLength ? -1 : (leftLength == rightLength ? 0 : 1);
                }
            }, ComparatorUtils.NATURAL_COMPARATOR));

    for (Method method : clazz.getDeclaredMethods()) {
        Annotation annotationInstance = method.getAnnotation(Paths.class);
        if (annotationInstance != null) {
            pathsOrderedByLength.addAll(Arrays.asList(((Paths) annotationInstance).value()));
        }
    }

    for (String routePath : pathsOrderedByLength) {
        LOGGER.info("Attaching route {} -> {}", routePath, clazz.getSimpleName());
        attachRoute(router, routePath, clazz);
    }
}

From source file:net.sourceforge.fenixedu.domain.residence.ResidenceYear.java

public Set<ResidenceMonth> getSortedMonths() {
    TreeSet<ResidenceMonth> months = new TreeSet<ResidenceMonth>(new BeanComparator("month"));
    months.addAll(getMonthsSet());// ww  w .  java2  s  . c  om
    return months;
}

From source file:info.magnolia.module.imaging.tools.ImageIOPluginsPage.java

/**
 * Removes duplicates and returns a sorted set of all entries in lowercase.
 *//*from www  .ja va  2 s .  c o m*/
protected static Collection<String> filter(String... formats) {
    final TreeSet<String> set = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
    set.addAll(Arrays.asList(formats));
    CollectionUtils.transform(set, new Transformer() {
        @Override
        public Object transform(Object input) {
            return ((String) input).toLowerCase();
        }
    });
    return set;
}

From source file:net.sourceforge.fenixedu.presentationTier.Action.phd.coordinator.providers.CurricularCourseDegreeExecutionSemesterProvider.java

@Override
public Object provide(Object source, Object currentValue) {
    final ManageEnrolmentsBean bean = (ManageEnrolmentsBean) source;

    final Collection<ExecutionSemester> result = new TreeSet<ExecutionSemester>(new ReverseComparator());

    for (final ExecutionYear executionYear : bean.getCurricularCourse().getDegreeCurricularPlan()
            .getExecutionYears()) {/* w  w  w .j a va2  s .co  m*/
        result.addAll(executionYear.getExecutionPeriodsSet());
    }

    return result;
}

From source file:mx.ecosur.multigame.grid.util.BeadString.java

public SortedSet<GridCell> getBeads() {
    if (beads == null)
        beads = new TreeSet<GridCell>(new CellComparator());
    return beads;
}

From source file:com.vrem.wifianalyzer.wifi.timegraph.DataManager.java

Set<WiFiDetail> addSeriesData(@NonNull GraphViewWrapper graphViewWrapper, @NonNull List<WiFiDetail> wiFiDetails,
        int levelMax) {
    Set<WiFiDetail> inOrder = new TreeSet<>(wiFiDetails);
    IterableUtils.forEach(inOrder, new AddDataClosure(graphViewWrapper, levelMax));
    adjustData(graphViewWrapper, inOrder);
    Set<WiFiDetail> result = getNewSeries(inOrder);
    xValue++;/* w w w. ja v  a2s .  c  om*/
    if (scanCount < MAX_SCAN_COUNT) {
        scanCount++;
    }
    if (scanCount == 2) {
        graphViewWrapper.setHorizontalLabelsVisible(true);
    }
    return result;
}

From source file:net.dv8tion.jda.core.utils.cache.impl.SortedSnowflakeCacheView.java

@Override
public SortedSet<T> asSet() {
    SortedSet<T> set = new TreeSet<>(comparator);
    elements.forEachValue(set::add);/*from w ww .  j a  va 2s  .c o m*/
    return Collections.unmodifiableSortedSet(set);
}

From source file:ca.travelagency.salesreports.PaymentModel.java

private SortedSet<InvoicePayment> getInvoicePayments() {
    return new TreeSet<InvoicePayment>(daoSupport.find(salesSearch.getInvoicePaymentCriteria()));
}

From source file:SuperPeer.java

/**
 * SuperPeer Constructor. It takes the number of bits in the key.
 *///from w ww  . ja v  a  2 s  .  com
SuperPeer(int _mbits) throws RemoteException, NoSuchAlgorithmException {
    lock = false;
    lg = new Logger("SuperPeer");
    mbits = _mbits;
    peertable = new TreeSet<PeerInfo>(new PeerInfoComparator());
    prng = SecureRandom.getInstance("SHA1PRNG");
    hasher = new SHA1Hasher(mbits);
    lg.log(Level.FINER, "SuperPeer started.");
}

From source file:net.sourceforge.fenixedu.dataTransferObject.InfoSiteEvaluationMarks.java

public Collection<Mark> getSortedMarks() {
    final Collection<Mark> sortedMarks = new TreeSet<Mark>(comparator);
    sortedMarks.addAll(getEvaluation().getMarksSet());
    return sortedMarks;
}