List of usage examples for com.google.common.collect HashMultiset create
public static <E> HashMultiset<E> create(Iterable<? extends E> elements)
From source file:org.simmetrics.tokenizers.AbstractTokenizer.java
@Override public Multiset<String> tokenizeToMultiset(final String input) { return HashMultiset.create(tokenizeToList(input)); }
From source file:org.javafunk.matchbox.implementations.HasOnlyItemsInAnyOrderMatcher.java
@Override protected boolean matchesSafely(final Iterable<E> actualItems, Description description) { boolean matches = true; final Multiset<E> actualMultiset = HashMultiset.create(actualItems); description.appendText("got "); if (actualMultiset.size() > 0) { description.appendValueList("", ", ", "", actualItems); } else {/*from w w w. j av a2s . c o m*/ description.appendText("empty collection"); if (expectedMultiset.size() != 0) { return false; } } if (actualMultiset.size() != expectedMultiset.size()) { description.appendText("\n").appendText("got collection with size ").appendValue(actualMultiset.size()) .appendText(" rather than ").appendValue(expectedMultiset.size()); matches = false; } if (checkForDifferences(expectedMultiset, actualMultiset, description, "expected but didn't get ")) { matches = false; } if (checkForDifferences(actualMultiset, expectedMultiset, description, "got but didn't expect ")) { matches = false; } return matches; }
From source file:com.android.quicksearchbox.ShortcutPromoter.java
void promoteShortcuts(SuggestionCursor shortcuts, int maxPromoted, ListSuggestionCursor promoted) { int shortcutCount = shortcuts == null ? 0 : shortcuts.getCount(); if (shortcutCount == 0) return;/*from w ww. j av a2 s . c om*/ HashMultiset<Source> sourceShortcutCounts = HashMultiset.create(shortcutCount); for (int i = 0; i < shortcutCount && promoted.getCount() < maxPromoted; i++) { shortcuts.moveTo(i); Source source = shortcuts.getSuggestionSource(); if (source != null && accept(shortcuts)) { int prevCount = sourceShortcutCounts.add(source, 1); int maxShortcuts = source.getMaxShortcuts(getConfig()); if (prevCount < maxShortcuts) { promoted.add(new SuggestionPosition(shortcuts)); } } } }
From source file:com.github.explainable.util.MoreAsserts.java
/** * Assert that {@code collection} consists of the specified elements. This method ignores order but * is sensitive to duplicate elements. The order of the arguments in this method is reversed * compared to most assertion methods: The collection we want to check comes <b>before</b> the list * of expected arguments.//from w ww . j a v a 2 s. c o m * * @param collection The collection of elements we want to check * @param elements The elements that are expected to comprise the collection */ public static <T> void assertElementsAnyOrder(Iterable<T> collection, T... elements) { assertEquals(HashMultiset.create(collection), HashMultiset.create(Arrays.asList(elements))); }
From source file:com.github.jeluard.stone.consolidator.ModeConsolidator.java
public ModeConsolidator(final int maxSamples) { this.values = HashMultiset.create(maxSamples); }
From source file:com.aljebra.scalar.condition.And.java
/** * Constructor.// w ww . j a v a 2 s. c o m * @param operands Predicates */ public And(final Predicate... operands) { this.opers = HashMultiset.create(Arrays.asList(operands)); }
From source file:com.continuuity.loom.layout.change.AddServicesChange.java
public AddServicesChange(Multiset<NodeLayout> countsPerNodeLayout, Set<String> services) { this.services = ImmutableSet.copyOf(services); this.countsPerNodeLayout = HashMultiset.create(countsPerNodeLayout); }
From source file:com.aljebra.metric.angle.Sum.java
/** * Constructor./*from w ww .j a v a 2 s .c om*/ * @param operands Sum operands */ public Sum(final Degrees... operands) { this.operands = HashMultiset.create(Arrays.asList(operands)); }
From source file:com.b2international.snowowl.snomed.datastore.index.update.ReferenceSetMembershipUpdater.java
public <B extends SnomedComponentDocument.SnomedComponentDocumentBuilder<B>> void update(B doc) { // get reference set membership fields final Multiset<String> newMemberOf = HashMultiset.create(currentMemberOf); final Multiset<String> newActiveMemberOf = HashMultiset.create(currentActiveMemberOf); processReferencingRefSetIds(newMemberOf, newActiveMemberOf); // re-add reference set membership fields doc.memberOf(newMemberOf);//from ww w . j av a2s . c om doc.activeMemberOf(newActiveMemberOf); }
From source file:com.aljebra.vector.Sum.java
/** * Constructor.// w w w .j a v a 2 s.c om * @param operands Sum operands */ @DimensionsEqual public Sum(final Vect... operands) { this.operands = HashMultiset.create(Arrays.asList(operands)); }