Example usage for java.util SortedSet add

List of usage examples for java.util SortedSet add

Introduction

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

Prototype

boolean add(E e);

Source Link

Document

Adds the specified element to this set if it is not already present (optional operation).

Usage

From source file:com.edmunds.etm.runtime.impl.ApplicationRepository.java

private Application createApplicationFromVip(ManagementVip vip) {
    VirtualServer vs = null;//from  w w w.  j  av a2s  . c  o  m
    if (vip.getHostAddress() != null) {
        Collection<ManagementPoolMember> vipMembers = vip.getPoolMembers().values();
        SortedSet<PoolMember> members = Sets.newTreeSet();
        for (ManagementPoolMember mpm : vipMembers) {
            members.add(new PoolMember(mpm.getHostAddress()));
        }
        String prefix = LoadBalancerController.VIRTUAL_SERVER_NAME_PREFIX;
        String serverName = VirtualServer.createServerName(prefix, vip.getMavenModule(), environment);
        vs = new VirtualServer(serverName, vip.getHostAddress(), members);
    }

    return new Application(vip.getMavenModule(), vip.getRules(), vip.getHttpMonitor(), vs);
}

From source file:com.benfante.minimark.controllers.AssessmentTemplateController.java

@ModelAttribute("tags")
public SortedSet<String> retriveTags(@RequestParam(value = "course.id", required = false) Long courseId) {
    SortedSet<String> tags = new TreeSet<String>();
    if (courseId != null) {
        List<TagQuestionLink> tagLinks = tagQuestionLinkDao.findByCourseId(courseId);
        for (TagQuestionLink tagQuestionLink : tagLinks) {
            tags.add(tagQuestionLink.getTag().getName());
        }/*from   ww  w.j a  v  a 2  s.  c o  m*/
    }
    return tags;
}

From source file:com.yahoo.pulsar.common.naming.NamespaceBundlesTest.java

@Test
public void testFindBundle() throws Exception {
    SortedSet<Long> partitions = Sets.newTreeSet();
    partitions.add(0l);
    partitions.add(0x40000000l);/*w  w w .  jav  a  2  s . c o m*/
    partitions.add(0xa0000000l);
    partitions.add(0xb0000000l);
    partitions.add(0xc0000000l);
    partitions.add(0xffffffffl);
    NamespaceBundles bundles = new NamespaceBundles(new NamespaceName("pulsar/global/ns1"), partitions,
            factory);
    DestinationName dn = DestinationName.get("persistent://pulsar/global/ns1/topic-1");
    NamespaceBundle bundle = bundles.findBundle(dn);
    assertTrue(bundle.includes(dn));

    dn = DestinationName.get("persistent://pulsar/use/ns2/topic-2");
    try {
        bundles.findBundle(dn);
        fail("Should have failed due to mismatched namespace name");
    } catch (IllegalArgumentException iae) {
        // OK, expected
    }

    Long hashKey = factory.getLongHashCode(dn.toString());
    // The following code guarantees that we have at least two ranges after the hashKey till the end
    SortedSet<Long> tailSet = partitions.tailSet(hashKey);
    tailSet.add(hashKey);
    // Now, remove the first range to ensure the hashKey is not included in <code>newPar</code>
    Iterator<Long> iter = tailSet.iterator();
    iter.next();
    SortedSet<Long> newPar = tailSet.tailSet(iter.next());

    try {
        bundles = new NamespaceBundles(dn.getNamespaceObject(), newPar, factory);
        bundles.findBundle(dn);
        fail("Should have failed due to out-of-range");
    } catch (ArrayIndexOutOfBoundsException iae) {
        // OK, expected
    }
}

From source file:com.wakacommerce.common.cache.StatisticsServiceImpl.java

@Override
public MBeanInfo getMBeanInfo() {
    SortedSet<String> names = new TreeSet<String>();
    for (Map.Entry<String, CacheStat> stats : cacheStats.entrySet()) {
        names.add(stats.getKey());
    }//from   w ww. j  a  va  2 s  .com
    MBeanAttributeInfo[] attrs = new MBeanAttributeInfo[names.size()];
    Iterator<String> it = names.iterator();
    for (int i = 0; i < attrs.length; i++) {
        String name = it.next();
        attrs[i] = new MBeanAttributeInfo(name, "java.lang.Double", name, true, // isReadable
                false, // isWritable
                false); // isIs
    }
    attrs = ArrayUtils.add(attrs,
            new MBeanAttributeInfo("LOG_RESOLUTION", "java.lang.Double", "LOG_RESOLUTION", true, // isReadable
                    true, // isWritable
                    false) // isIs
    );
    MBeanOperationInfo[] opers = { new MBeanOperationInfo("activate", "Activate statistic logging", null, // no parameters
            "void", MBeanOperationInfo.ACTION),
            new MBeanOperationInfo("disable", "Disable statistic logging", null, // no parameters
                    "void", MBeanOperationInfo.ACTION) };
    return new MBeanInfo("com.wakacommerce:name=StatisticsService." + appName, "Runtime Statistics", attrs,
            null, // constructors
            opers, null); // notifications
}

From source file:org.stockwatcher.data.cassandra.UserDAOImpl.java

@Override
public SortedSet<User> getUsers(StatementOptions options) {
    SortedSet<User> users = new TreeSet<User>();
    try {/*from  www.j ava2s. c o m*/
        BoundStatement bs = selectUsers.bind();
        for (Row row : execute(bs, options)) {
            UUID userId = row.getUUID("user_id");
            users.add(createUser(row, watchListDAO.getWatchListCountByUserId(options, userId)));
        }
    } catch (DriverException e) {
        throw new DAOException(e);
    }
    return users;
}

From source file:org.atemsource.atem.impl.infrastructure.HandlerLocatorImpl.java

private void addBean(Bean<H> bean, Class<T> modelType) {
    SortedSet<Bean<H>> SortedSet = sortedTypeHandlerBeans.get(modelType);
    if (SortedSet == null) {
        SortedSet = new TreeSet<Bean<H>>(new OrderComparator());
        sortedTypeHandlerBeans.put(modelType, SortedSet);
    }/*w ww.j ava 2  s. c  o m*/
    SortedSet.add(bean);
}

From source file:com.aurel.track.item.link.ItemLinkBL.java

private static Map<Integer, SortedSet<Integer>> getSuccOrPredLinkedWorkItemIDMaps(
        List<TWorkItemLinkBean> workItemLinksList, boolean predToSucc) {
    Map<Integer, SortedSet<Integer>> workItemIDsMap = new HashMap<Integer, SortedSet<Integer>>();
    Iterator<TWorkItemLinkBean> iterator = workItemLinksList.iterator();
    while (iterator.hasNext()) {
        TWorkItemLinkBean workItemLinkBean = iterator.next();
        Integer linkPred = workItemLinkBean.getLinkPred();
        Integer linkSucc = workItemLinkBean.getLinkSucc();
        Integer key = null;//from  w  w w.ja  v a  2 s.c o m
        Integer value = null;
        if (predToSucc) {
            key = linkPred;
            value = linkSucc;
        } else {
            key = linkSucc;
            value = linkPred;
        }
        SortedSet<Integer> linkSet = workItemIDsMap.get(key);
        if (linkSet == null) {
            linkSet = new TreeSet<Integer>();
            workItemIDsMap.put(key, linkSet);
        }
        linkSet.add(value);
    }
    return workItemIDsMap;
}

From source file:dk.statsbiblioteket.netark.dvenabler.wrapper.SortedDocValuesWrapper.java

private List<BytesRef> fill() throws IOException {
    final SortedSet<BytesRef> values = new TreeSet<>();
    for (int docID = 0; docID < reader.maxDoc(); docID++) {
        String value = reader.document(docID, FIELDS).get(field.getName());
        //System.out.println(value);
        if (value != null) {
            values.add(new BytesRef(value));
        }//w  ww  .j a va 2s.c o  m
    }
    return new ArrayList<>(values);
}

From source file:edu.harvard.med.screensaver.ui.arch.util.converter.EmptyWellsConverter.java

private Set<Integer> getFullRows(Set<WellName> wellNames) {
    int[] rowCounts = new int[ScreensaverConstants.DEFAULT_PLATE_SIZE.getRows()];
    Arrays.fill(rowCounts, 0, rowCounts.length, 0);
    for (WellName wellName : wellNames) {
        rowCounts[wellName.getRowIndex()]++;
    }// www  . java 2s  .  c om
    SortedSet<Integer> fullRowIndexes = Sets.newTreeSet();
    for (int rowIndex = 0; rowIndex < rowCounts.length; ++rowIndex) {
        if (rowCounts[rowIndex] == ScreensaverConstants.DEFAULT_PLATE_SIZE.getColumns()) {
            fullRowIndexes.add(rowIndex);
        }
    }
    return fullRowIndexes;
}

From source file:edu.harvard.med.screensaver.ui.arch.util.converter.EmptyWellsConverter.java

private SortedSet<Integer> getFullColumns(Set<WellName> wellNames) {
    int[] columnCounts = new int[ScreensaverConstants.DEFAULT_PLATE_SIZE.getColumns()];
    Arrays.fill(columnCounts, 0, columnCounts.length, 0);
    for (WellName wellName : wellNames) {
        columnCounts[wellName.getColumnIndex()]++;
    }//from   ww  w . ja  v  a 2 s  . c o m
    SortedSet<Integer> fullColumnIndexes = Sets.newTreeSet();
    for (int colIndex = 0; colIndex < columnCounts.length; ++colIndex) {
        if (columnCounts[colIndex] == ScreensaverConstants.DEFAULT_PLATE_SIZE.getRows()) {
            fullColumnIndexes.add(colIndex);
        }
    }
    return fullColumnIndexes;
}