Example usage for com.google.common.collect ImmutableMultiset copyOf

List of usage examples for com.google.common.collect ImmutableMultiset copyOf

Introduction

In this page you can find the example usage for com.google.common.collect ImmutableMultiset copyOf.

Prototype

public static <E> ImmutableMultiset<E> copyOf(Iterator<? extends E> elements) 

Source Link

Document

Returns an immutable multiset containing the given elements, in the "grouped iteration order" described in the class documentation.

Usage

From source file:pl.nn44.battleship.util.other.Lists.java

public static <T> boolean equalsIgnoreOrder(List<T> a, List<T> b) {
    return a == b || ImmutableMultiset.copyOf(a).equals(ImmutableMultiset.copyOf(b));
}

From source file:com.google.errorprone.StatisticsCollector.java

/** Returns a new statistics collector that will successfully count keys added to it. */
static StatisticsCollector createCollector() {
    return new StatisticsCollector() {
        private final Multiset<String> strings = HashMultiset.create();

        @Override//from w  w w  . ja  v  a  2s . c  om
        public void incrementCounter(String key, int count) {
            strings.add(key, count);
        }

        @Override
        public ImmutableMultiset<String> counters() {
            return ImmutableMultiset.copyOf(strings);
        }
    };
}

From source file:ai.grakn.engine.tasks.mock.MockBackgroundTask.java

public static ImmutableMultiset<TaskId> completedTasks() {
    return ImmutableMultiset.copyOf(COMPLETED_TASKS);
}

From source file:ai.grakn.engine.tasks.mock.MockBackgroundTask.java

public static ImmutableMultiset<TaskId> cancelledTasks() {
    return ImmutableMultiset.copyOf(CANCELLED_TASKS);
}

From source file:com.google.uzaygezen.core.MoreAsserts.java

/**
 * Asserts that {@code actual} contains precisely the elements
 * {@code expected}, in any order.  Both collections may contain
 * duplicates, and this method will only pass if the quantities are
 * exactly the same./*from   www  . ja v  a  2 s .c o m*/
 */
public static void assertContentsAnyOrder(String message, Iterable<?> actual, Object... expected) {
    Assert.assertEquals(message, ImmutableMultiset.copyOf(expected), ImmutableMultiset.copyOf(actual));
}

From source file:org.apache.bigtop.datagenerators.bigpetstore.generators.transaction.CustomerTransactionParameters.java

public CustomerTransactionParameters(Multiset<PetSpecies> petCounts, double averageTransactionTriggerTime,
        double averagePurchaseTriggerTime) {
    this.petCounts = ImmutableMultiset.copyOf(petCounts);
    this.averageTransactionTriggerTime = averageTransactionTriggerTime;
    this.averagePurchaseTriggerTime = averagePurchaseTriggerTime;
}

From source file:com.continuuity.loom.layout.ClusterLayout.java

public ClusterLayout(Constraints constraints, Multiset<NodeLayout> layout) {
    this.constraints = constraints;
    this.layout = ImmutableMultiset.copyOf(layout);
    this.serviceCounts = HashMultiset.create();
    for (Multiset.Entry<NodeLayout> entry : layout.entrySet()) {
        for (String service : entry.getElement().getServiceNames()) {
            serviceCounts.add(service, entry.getCount());
        }/*from   ww w .ja  v a  2 s  . c  o  m*/
    }
}

From source file:com.bouncestorage.chaoshttpproxy.ChaosConfig.java

Properties getProperties() {
    Properties properties = new Properties();
    for (Multiset.Entry<Failure> entry : ImmutableMultiset.copyOf(failures).entrySet()) {
        properties.setProperty(entry.getElement().toPropertyName(), String.valueOf(entry.getCount()));
    }/* w w  w. j a v a  2  s .c  o m*/
    return properties;
}

From source file:com.github.lstephen.ootp.ai.selection.SlotAssignments.java

public ImmutableMultiset<Slot> getRemainingSlots() {
    return ImmutableMultiset.copyOf(remaining);
}

From source file:com.proofpoint.http.client.StaticHttpServiceBalancerProvider.java

StaticHttpServiceBalancerProvider(String type, Collection<URI> baseUris,
        Key<HttpServiceBalancerConfig> balancerConfigKey) {
    this.type = requireNonNull(type, "type is null");
    this.baseUris = ImmutableMultiset.copyOf(baseUris);
    this.balancerConfigKey = requireNonNull(balancerConfigKey, "balancerConfigKey is null");
}