Example usage for com.google.common.collect SortedMultiset addAll

List of usage examples for com.google.common.collect SortedMultiset addAll

Introduction

In this page you can find the example usage for com.google.common.collect SortedMultiset addAll.

Prototype

boolean addAll(Collection<? extends E> c);

Source Link

Document

Adds all of the elements in the specified collection to this collection (optional operation).

Usage

From source file:c5db.interfaces.replication.QuorumConfiguration.java

private static long getGreatestIndexCommittedByMajority(Set<Long> peers, Map<Long, Long> peersLastAckedIndex) {
    SortedMultiset<Long> committedIndexes = TreeMultiset.create();
    committedIndexes.addAll(peers.stream().map(peerId -> peersLastAckedIndex.getOrDefault(peerId, 0L))
            .collect(Collectors.toList()));
    return Iterables.get(committedIndexes.descendingMultiset(), calculateNumericalMajority(peers.size()) - 1);
}

From source file:cc.kave.commons.model.groum.comparator.ExasVectorBuilder.java

private SortedMultiset<PQNode> buildPQNodes(IGroum groum, Node node) {
    SortedMultiset<PQNode> pqNodes = TreeMultiset.create();
    Set<Node> successors = groum.getSuccessors(node);
    int numberOfPredecessors = groum.getPredecessors(node).size();
    pqNodes.add(new PQNode(node, numberOfPredecessors, successors.size()));
    for (Node successor : successors) {
        pqNodes.addAll(buildPQNodes(groum, successor));
    }/*from   w ww . j  ava 2s . c  o  m*/
    return pqNodes;
}

From source file:cc.kave.commons.model.groum.comparator.ExasVectorBuilder.java

private SortedMultiset<Path> buildNPaths(IGroum groum, Path base, Node newNode) {
    SortedMultiset<Path> paths = TreeMultiset.create();
    Path extension = base.getExtension(newNode);
    Set<Node> successors = groum.getSuccessors(newNode);

    if (ComputeSubPaths) {
        Path tail = extension;//from   w  w  w.  j a  v  a 2  s. c  o  m
        do {
            paths.add(tail);
            tail = tail.getTail();
        } while (!tail.isEmpty());
    } else if (successors.isEmpty()) {
        paths.add(extension);
    }

    for (Node suc : successors) {
        paths.addAll(buildNPaths(groum, extension, suc));
    }
    return paths;
}