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() 

Source Link

Document

Constructs a new, empty tree set, sorted according to the natural ordering of its elements.

Usage

From source file:org.sventon.rss.RssFeedGeneratorTest.java

@Test
public void testGenerateFeedRSS20() throws Exception {
    final DefaultRssFeedGenerator generator = new DefaultRssFeedGenerator();
    generator.setFeedType("rss_2.0");
    generator.setLogMessageLength(20);//  ww w .j a v a 2s  .c o m
    generator.setDateFormat("yyyyMMdd HH:mm:ss");

    List<LogEntry> logEntries = new ArrayList<LogEntry>();
    SortedSet<ChangedPath> changedPaths;

    final String logMessage = "&lt; &gt; / &amp; ' ; \\";

    changedPaths = new TreeSet<ChangedPath>();
    changedPaths.add(new ChangedPath("/file1.java", null, 1, ChangeType.MODIFIED));
    changedPaths.add(new ChangedPath("/file2.html", null, 1, ChangeType.DELETED));
    changedPaths.add(new ChangedPath("/file3.abc", null, 1, ChangeType.ADDED));
    changedPaths.add(new ChangedPath("/file4.def", null, 1, ChangeType.REPLACED));
    logEntries.add(TestUtils.createLogEntry(1, "jesper", new Date(), logMessage, changedPaths));

    changedPaths = new TreeSet<ChangedPath>();
    changedPaths.add(new ChangedPath("/file1.java", null, 2, ChangeType.MODIFIED));
    changedPaths.add(new ChangedPath("/file2.html", null, 2, ChangeType.DELETED));
    changedPaths.add(new ChangedPath("/file3.abc", null, 2, ChangeType.ADDED));
    changedPaths.add(new ChangedPath("/file4.def", "/file44.def", 1, ChangeType.REPLACED));
    logEntries.add(TestUtils.createLogEntry(2, "jesper", new Date(), "Another\nlog message.", changedPaths));

    final File tempFile = File.createTempFile("sventon-rss-test", null);
    final PrintWriter pw = new PrintWriter(tempFile);

    final MockHttpServletRequest req = new MockHttpServletRequest("get", "http://localhost:8888/svn/");
    final MockHttpServletResponse res = new MockHttpServletResponse() {
        public PrintWriter getWriter() throws UnsupportedEncodingException {
            return pw;
        }
    };

    generator.outputFeed(new RepositoryConfiguration("defaultsvn"), logEntries, req, res);
    pw.flush();
    pw.close();

    if (tempFile.exists()) {
        tempFile.delete();
    } else {
        fail("No rss feed file was created in " + TestUtils.TEMP_DIR);
    }
}

From source file:org.mzd.shap.spring.web.WorkBenchController.java

@SuppressWarnings("unchecked")
protected Collection<Integer> getSessionItemIds(HttpSession session) {
    Object mutex = WebUtils.getSessionMutex(session);
    synchronized (mutex) {
        Object obj = session.getAttribute(SESSION_ATTR_ITEMID);
        if (obj == null) {
            obj = new TreeSet<Integer>();
            session.setAttribute(SESSION_ATTR_ITEMID, obj);
        }/*from   ww w.j  ava 2s  .co  m*/
        return (Collection<Integer>) obj;
    }
}

From source file:org.excalibur.discovery.ws.client.ClustersClient.java

public static <E> NavigableSet<E> convertValue(List<?> members, Class<E> type) {
    NavigableSet<E> nodes = new TreeSet<E>();

    if (members != null) {
        for (Object member : members) {
            nodes.add(RESOURCE_MAPPER.convertValue(member, type));
        }/*  w  w  w .  j  a v a 2  s . co m*/
    }

    return nodes;
}

From source file:la.alsocan.symbiot.api.to.NextBindingTo.java

public NextBindingTo() {
    this.legalBindingTypes = new TreeSet<>();
    this.legalSourceNodes = new TreeSet<>();
}

From source file:com.inmobi.messaging.consumer.databus.TestConsumerPartitionMinList.java

@BeforeTest
public void setup() throws Exception {
    ClientConfig config = ClientConfig.loadFromClasspath("messaging-consumer-conf16.properties");

    expectedPartitionMinList = new TreeSet<Integer>();
    testConsumer = new DatabusConsumer();
    testConsumer.initializeConfig(config);
    chkpointPath = config.getString(DatabusConsumerConfig.checkpointDirConfig);
    if (totalNumberOfConsumers > 0 && consumerId > 0) {
        expectedPartitionMinList();//from w  w  w .  j a v  a 2  s.  c  om
    }
}

From source file:edu.umass.cs.reconfiguration.reconfigurationutils.ReconfigurableSampleNodeConfig.java

@Override
public Set<Integer> getActiveReplicas() {
    Set<Integer> allNodes = this.getNodeIDs();
    Set<Integer> actives = new TreeSet<Integer>();
    int count = 0;
    for (Integer id : allNodes) {
        actives.add(numberToActive(id));
        if (++count == this.numActives)
            break;
    }/* www . ja  va 2 s .  c om*/
    return actives;

}

From source file:com.insightml.utils.Collections.java

public static <T> Set<T> sort(final Set<T> items) {
    final Set<T> set = new TreeSet<>();
    set.addAll(items);//w  w  w  .j  ava  2  s.c  o m
    return set;
}

From source file:com.alibaba.jstorm.task.backpressure.TargetBackpressureInfo.java

public TargetBackpressureInfo(EventType backpressureStatus, int flowCtrlTime, long time) {
    this.tasks = new TreeSet<Integer>();
    this.backpressureStatus = backpressureStatus;
    this.flowCtrlTime = flowCtrlTime;
    this.timeStamp = time;
}

From source file:com.berwickheights.spring.svc.security.UserRolesSvcImpl.java

@Override
public GrantedAuthority[] getUserRoles(Set<Short> userRoles) {
    Set<GrantedAuthority> auths = new TreeSet<GrantedAuthority>();
    for (Short userRole : userRoles) {
        Set<GrantedAuthority> authsForRole = rolesMap.get(userRole);
        if (authsForRole == null) {
            logger.warn("No authorities for given userRole: " + userRole);
        } else {/*from  w  w  w. j  a  v a2  s .co m*/
            auths.addAll(authsForRole);
        }
    }

    return auths.toArray(new GrantedAuthority[auths.size()]);
}

From source file:com.yahoo.omid.tso.Bucket.java

public synchronized Set<Long> abortUncommited(long id) {
    int lastCommited = (int) (id % BUCKET_SIZE);

    Set<Long> aborted = new TreeSet<Long>();
    if (allCommited()) {
        return aborted;
    }//  w w w.  j  a v  a  2 s  . c  om

    LOG.trace("Performing scanning...");

    for (int i = transactions.nextClearBit(firstUncommited); i >= 0
            && i <= lastCommited; i = transactions.nextClearBit(i + 1)) {
        aborted.add(((long) position) * BUCKET_SIZE + i);
        commit(i);
    }

    firstUncommited = lastCommited + 1;

    return aborted;
}