Example usage for java.util.concurrent ConcurrentSkipListSet ConcurrentSkipListSet

List of usage examples for java.util.concurrent ConcurrentSkipListSet ConcurrentSkipListSet

Introduction

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

Prototype

ConcurrentSkipListSet(ConcurrentNavigableMap<E, Object> m) 

Source Link

Document

For use by submaps

Usage

From source file:gemlite.core.internal.support.context.GemliteIndexContext.java

public void putIndexNamesByRegion(IndexRegion bean) {
    Set<IndexRegion> list = regionMap.get(bean.regionName());
    if (list == null) {
        list = new ConcurrentSkipListSet<IndexRegion>(new Comparator<IndexRegion>() {

            @Override/*from  ww  w  . ja va  2  s  .c  om*/
            public int compare(IndexRegion o1, IndexRegion o2) {

                return new CompareToBuilder().append(o1.orderNo(), o2.orderNo())
                        .append(o1.indexName(), o2.indexName()).toComparison();
            }
        });

        regionMap.put(bean.regionName(), list);
    }

    list.add(bean);
}

From source file:com.enitalk.configs.DateCache.java

@Bean(name = "skipCache")
public LoadingCache<String, ConcurrentSkipListSet<DateTime>> datesMap() {
    CacheBuilder<Object, Object> ccc = CacheBuilder.newBuilder();
    ccc.expireAfterWrite(2, TimeUnit.MINUTES);

    LoadingCache<String, ConcurrentSkipListSet<DateTime>> cache = ccc
            .build(new CacheLoader<String, ConcurrentSkipListSet<DateTime>>() {

                @Override//from w w w.j a  v  a  2s . co  m
                public ConcurrentSkipListSet<DateTime> load(String key) throws Exception {
                    try {
                        HashMap teachers = mongo.findOne(Query.query(Criteria.where("i").is(key)),
                                HashMap.class, "teachers");
                        ObjectNode teacherJson = jackson.convertValue(teachers, ObjectNode.class);
                        String timeZone = teacherJson.at("/calendar/timeZone").asText();

                        NavigableSet<DateTime> set = days(teacherJson.path("schedule"), timeZone, teacherJson);

                        DateTimeZone dzz = DateTimeZone.forID(timeZone);
                        DateTimeFormatter df = ISODateTimeFormat.dateTimeNoMillis().withZone(dzz);

                        byte[] events = calendar.busyEvents(jackson.createObjectNode().put("id", key));
                        JsonNode evs = jackson.readTree(events);
                        Iterator<JsonNode> its = evs.iterator();
                        TreeSet<DateTime> dates = new TreeSet<>();
                        while (its.hasNext()) {
                            String date = its.next().asText();
                            DateTime av = df.parseDateTime(date).toDateTime(DateTimeZone.UTC);
                            dates.add(av);
                        }

                        set.removeAll(dates);

                        logger.info("Dates for i {} {}", key, set);

                        return new ConcurrentSkipListSet<>(set);

                    } catch (Exception e) {
                        logger.error(ExceptionUtils.getFullStackTrace(e));
                    }
                    return null;
                }

            });

    return cache;
}

From source file:org.apache.hadoop.hbase.regionserver.Memcache.java

static ConcurrentSkipListSet<KeyValue> createSet(final KeyValue.KVComparator c) {
    return new ConcurrentSkipListSet<KeyValue>(c);
}

From source file:gemlite.core.internal.measurement.index.BigComparator.java

public AbstractIndexStat() {
    maxHistory = new ConcurrentSkipListSet<>(new BigComparator());
    recentHistory = new ConcurrentSkipListSet<>(new RecentComparator());
}

From source file:gemlite.core.internal.support.context.GemliteIndexContext.java

public void putIndexNamesByTestRegion(IndexRegion bean) {
    Set<IndexRegion> list = testRegionMap.get(bean.regionName());
    if (list == null) {
        list = new ConcurrentSkipListSet<IndexRegion>(new Comparator<IndexRegion>() {

            @Override/*from w  w w.java  2  s . c  o  m*/
            public int compare(IndexRegion o1, IndexRegion o2) {

                return new CompareToBuilder().append(o1.orderNo(), o2.orderNo())
                        .append(o1.indexName(), o2.indexName()).toComparison();
            }
        });

        testRegionMap.put(bean.regionName(), list);
    }

    list.add(bean);
}

From source file:com.tussle.main.Utility.java

public static Collection<ProjectionVector> prunedProjections(Collection<ProjectionVector> vectors) {
    SortedSet<ProjectionVector> sortedVectors = new ConcurrentSkipListSet<>(
            Comparator.comparingDouble((ProjectionVector p) -> -p.magnitude()));
    sortedVectors.addAll(vectors);//from   w w w  .  java2 s  .  co m
    if (isPruned(sortedVectors))
        return sortedVectors;
    double reduceMagnitude = 0;
    Iterator<ProjectionVector> i = sortedVectors.iterator();
    ProjectionVector p0 = i.next();
    ProjectionVector p1 = i.next();
    double cos0 = p0.xNorm();
    double sin0 = p0.yNorm();
    double cos1 = p1.xNorm();
    double sin1 = p1.yNorm();
    //zeroth on the right, first on the left
    if (cos0 * sin1 < cos1 * sin0) {
        double tmpcos = cos1;
        double tmpsin = sin1;
        cos1 = cos0;
        sin1 = sin0;
        cos0 = tmpcos;
        sin0 = tmpsin;
    }
    while (i.hasNext()) {
        ProjectionVector next = i.next();
        double nextcos = next.xNorm();
        double nextsin = next.yNorm();
        if (nextcos * sin0 >= cos0 * nextsin && cos1 * nextsin >= nextcos * sin1) {
            //Case 0: Within cross product bounds
        } else if (nextcos * sin0 >= cos0 * nextsin) {
            //Case 1: Over the left, extend those bounds
            cos1 = nextcos;
            sin1 = nextsin;
        } else if (cos1 * nextsin >= nextcos * sin1) {
            //Case 2: Over the right, extend those bounds
            cos0 = nextcos;
            sin0 = nextsin;
        } else {
            //Case 3: Opposite side, immediately return false
            reduceMagnitude = next.magnitude();
            break;
        }
    }
    //Now given reduceMagnitude, remove elements with lesser magnitude and
    //reduce the magnitude of remaining elements
    if (Double.isFinite(reduceMagnitude)) {
        for (Iterator<ProjectionVector> j = sortedVectors.iterator(); j.hasNext();) {
            ProjectionVector vec = j.next();
            if (vec.magnitude() <= reduceMagnitude)
                j.remove();
            else
                vec = new ProjectionVector(vec.xNorm(), vec.yNorm(), vec.magnitude() - reduceMagnitude);
        }
    }
    return sortedVectors;
}

From source file:com.redhat.example.rules.unittest.RuleCoverageLogger.java

/**
 * initialize (register) package//from  ww  w  .j  av a  2  s  .c  o m
 * @param kieBase
 */
private void initPackage(KiePackage kiePackage) {
    if (!initializedPackageSet.add(kiePackage.getName())) {
        // already initialized
        return;
    }
    final RuleComparator ruleComparator = new RuleComparator();
    for (Rule rule : kiePackage.getRules()) {
        Boolean previous = ruleCoverageMap.put(rule, Boolean.FALSE);
        if (previous != null) {
            // already registered (concurrent access)
            ruleCoverageMap.put(rule, previous);
        }
        String ruleGroupName = ((RuleImpl) rule).getAgendaGroup();
        if (ruleGroupName == null) {
            ruleGroupName = ((RuleImpl) rule).getRuleFlowGroup();
        }
        ruleGroupName = StringUtils.isBlank(ruleGroupName) ? "default" : ruleGroupName;
        Set<Rule> rules = ruleGroupToRulesMap.get(ruleGroupName);
        if (rules == null) {
            rules = new ConcurrentSkipListSet<Rule>(ruleComparator);
            ruleGroupToRulesMap.put(ruleGroupName, rules);
        }
        rules.add(rule);
    }
}

From source file:com.coinblesk.payments.WalletService.java

public WalletService() {
    walletServiceBinder = new WalletServiceBinder();
    walletEventListener = new CoinbleskWalletEventListener();
    bitcoinjThreadFactory = new ContextPropagatingThreadFactory("WalletServiceThreads");

    addressHashes = new ConcurrentHashMap<>();
    addresses = new ConcurrentSkipListSet<>(new LockTime.TimeCreatedComparator(true));
}

From source file:org.sleuthkit.autopsy.timeline.ui.listvew.ListTimeline.java

/**
 * Constructor/*  w w  w  .ja v a  2 s . c  o m*/
 *
 * @param controller The controller for this timeline
 */
ListTimeline(TimeLineController controller) {

    this.controller = controller;
    sleuthkitCase = controller.getAutopsyCase().getSleuthkitCase();
    tagsManager = controller.getAutopsyCase().getServices().getTagsManager();
    FXMLConstructor.construct(this, ListTimeline.class, "ListTimeline.fxml"); //NON-NLS
    this.visibleEvents = new ConcurrentSkipListSet<>(Comparator.comparing(table.getItems()::indexOf));
}

From source file:net.joshdevins.rabbitmq.client.ha.HaConnectionFactory.java

/**
 * Allows setting a {@link Set} of {@link HaConnectionListener}s. This is
 * ammenable for Spring style property setting. Note that this will override
 * any existing listeners!//from w ww .  java  2 s  .com
 */
public void setHaConnectionListener(final Set<HaConnectionListener> listeners) {

    Validate.notEmpty(listeners, "listeners are required and none can be null");
    this.listeners = new ConcurrentSkipListSet<HaConnectionListener>(listeners);
}