Example usage for com.google.common.collect Multisets removeOccurrences

List of usage examples for com.google.common.collect Multisets removeOccurrences

Introduction

In this page you can find the example usage for com.google.common.collect Multisets removeOccurrences.

Prototype

public static boolean removeOccurrences(Multiset<?> multisetToModify, Multiset<?> occurrencesToRemove) 

Source Link

Document

For each occurrence of an element e in occurrencesToRemove , removes one occurrence of e in multisetToModify .

Usage

From source file:ai.grakn.graql.internal.gremlin.Plan.java

Fragment pop() {
    Fragment fragment = fragments.pop();
    fragmentSets.remove(fragment.getEquivalentFragmentSet());
    Multisets.removeOccurrences(names, fragment.getVariableNames());
    totalCost -= costs.pop();// w  w w.  j  a v  a  2s.co m
    return fragment;
}

From source file:uk.ac.horizon.artcodes.detect.handler.MarkerCodeDetectionHandler.java

protected Multiset<String> countMarkers(Collection<Marker> markers) {
    final Collection<String> removals = new HashSet<>(markerCounts.elementSet());

    for (Marker marker : markers) {
        final String markerCode = marker.toString();
        final int count = markerCounts.count(markerCode);
        int max = maxFor(markerCode);
        if (count > max) {
            markerCounts.setCount(markerCode, max);
        }/*from w  ww  . j  av  a 2s . c  om*/

        //increase occurrence if this marker is already in the list.
        markerCounts.add(markerCode, this.awardFor(markerCode));
        removals.remove(markerCode);
    }

    Multisets.removeOccurrences(markerCounts, removals);

    return markerCounts;
}