Codota Logo
Multiset.addAll
Code IndexAdd Codota to your IDE (free)

How to use
addAll
method
in
com.google.common.collect.Multiset

Best Java code snippets using com.google.common.collect.Multiset.addAll (Showing top 20 results out of 468)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
Charset c =
  • Codota IconString charsetName;Charset.forName(charsetName)
  • Codota IconCharset.defaultCharset()
  • Codota IconContentType contentType;contentType.getCharset()
  • Smart code suggestions by Codota
}
origin: SonarSource/sonarqube

@Override
public void aggregate(LanguageDistributionCounter counter) {
 multiset.addAll(counter.multiset);
}
origin: google/guava

/**
 * Returns a {@code Collector} that accumulates elements into a multiset created via the specified
 * {@code Supplier}, whose elements are the result of applying {@code elementFunction} to the
 * inputs, with counts equal to the result of applying {@code countFunction} to the inputs.
 * Elements are added in encounter order.
 *
 * <p>If the mapped elements contain duplicates (according to {@link Object#equals}), the element
 * will be added more than once, with the count summed over all appearances of the element.
 *
 * <p>Note that {@code stream.collect(toMultiset(function, e -> 1, supplier))} is equivalent to
 * {@code stream.map(function).collect(Collectors.toCollection(supplier))}.
 *
 * @since 22.0
 */
public static <T, E, M extends Multiset<E>> Collector<T, ?, M> toMultiset(
  java.util.function.Function<? super T, E> elementFunction,
  java.util.function.ToIntFunction<? super T> countFunction,
  java.util.function.Supplier<M> multisetSupplier) {
 checkNotNull(elementFunction);
 checkNotNull(countFunction);
 checkNotNull(multisetSupplier);
 return Collector.of(
   multisetSupplier,
   (ms, t) -> ms.add(elementFunction.apply(t), countFunction.applyAsInt(t)),
   (ms1, ms2) -> {
    ms1.addAll(ms2);
    return ms1;
   });
}
origin: SonarSource/sonarqube

void add(Counter counter) {
 unresolved += counter.unresolved;
 open += counter.open;
 reopened += counter.reopened;
 confirmed += counter.confirmed;
 falsePositives += counter.falsePositives;
 wontFix += counter.wontFix;
 severityBag.addAll(counter.severityBag);
 typeBag.addAll(counter.typeBag);
}
origin: goldmansachs/gs-collections

@Benchmark
public void guava()
{
  Multiset<Integer> result = HashMultiset.create();
  for (int i = 0; i < 1000; i++)
  {
    result.addAll(this.integersGuava);
  }
}
origin: google/guava

/**
 * Returns a {@code Collector} that accumulates elements into an {@code ImmutableMultiset} whose
 * elements are the result of applying {@code elementFunction} to the inputs, with counts equal to
 * the result of applying {@code countFunction} to the inputs.
 *
 * <p>If the mapped elements contain duplicates (according to {@link Object#equals}), the first
 * occurrence in encounter order appears in the resulting multiset, with count equal to the sum of
 * the outputs of {@code countFunction.applyAsInt(t)} for each {@code t} mapped to that element.
 *
 * @since 22.0
 */
public static <T, E> Collector<T, ?, ImmutableMultiset<E>> toImmutableMultiset(
  Function<? super T, ? extends E> elementFunction, ToIntFunction<? super T> countFunction) {
 checkNotNull(elementFunction);
 checkNotNull(countFunction);
 return Collector.of(
   LinkedHashMultiset::create,
   (multiset, t) ->
     multiset.add(checkNotNull(elementFunction.apply(t)), countFunction.applyAsInt(t)),
   (multiset1, multiset2) -> {
    multiset1.addAll(multiset2);
    return multiset1;
   },
   (Multiset<E> multiset) -> copyFromEntries(multiset.entrySet()));
}
origin: google/guava

/**
 * Returns a {@code Collector} that accumulates elements into an {@code ImmutableSortedMultiset}
 * whose elements are the result of applying {@code elementFunction} to the inputs, with counts
 * equal to the result of applying {@code countFunction} to the inputs.
 *
 * <p>If the mapped elements contain duplicates (according to {@code comparator}), the first
 * occurrence in encounter order appears in the resulting multiset, with count equal to the sum of
 * the outputs of {@code countFunction.applyAsInt(t)} for each {@code t} mapped to that element.
 *
 * @since 22.0
 */
public static <T, E> Collector<T, ?, ImmutableSortedMultiset<E>> toImmutableSortedMultiset(
  Comparator<? super E> comparator,
  Function<? super T, ? extends E> elementFunction,
  ToIntFunction<? super T> countFunction) {
 checkNotNull(comparator);
 checkNotNull(elementFunction);
 checkNotNull(countFunction);
 return Collector.of(
   () -> TreeMultiset.create(comparator),
   (multiset, t) ->
     multiset.add(checkNotNull(elementFunction.apply(t)), countFunction.applyAsInt(t)),
   (multiset1, multiset2) -> {
    multiset1.addAll(multiset2);
    return multiset1;
   },
   (Multiset<E> multiset) -> copyOfSortedEntries(comparator, multiset.entrySet()));
}
origin: google/guava

@CollectionFeature.Require(SUPPORTS_ADD)
public void testAddAll_emptySet() {
 assertFalse(getMultiset().addAll(Collections.<E>emptySet()));
 expectUnchanged();
}
origin: wildfly/wildfly

/**
 * Returns a {@code Collector} that accumulates elements into a multiset created via the specified
 * {@code Supplier}, whose elements are the result of applying {@code elementFunction} to the
 * inputs, with counts equal to the result of applying {@code countFunction} to the inputs.
 * Elements are added in encounter order.
 *
 * <p>If the mapped elements contain duplicates (according to {@link Object#equals}), the element
 * will be added more than once, with the count summed over all appearances of the element.
 *
 * <p>Note that {@code stream.collect(toMultiset(function, e -> 1, supplier))} is equivalent to
 * {@code stream.map(function).collect(Collectors.toCollection(supplier))}.
 *
 * @since 22.0
 */
public static <T, E, M extends Multiset<E>> Collector<T, ?, M> toMultiset(
  java.util.function.Function<? super T, E> elementFunction,
  java.util.function.ToIntFunction<? super T> countFunction,
  java.util.function.Supplier<M> multisetSupplier) {
 checkNotNull(elementFunction);
 checkNotNull(countFunction);
 checkNotNull(multisetSupplier);
 return Collector.of(
   multisetSupplier,
   (ms, t) -> ms.add(elementFunction.apply(t), countFunction.applyAsInt(t)),
   (ms1, ms2) -> {
    ms1.addAll(ms2);
    return ms1;
   });
}
origin: google/guava

@Override
protected Multiset<String> create(String[] elements) {
 Multiset<String> multiset = LinkedHashMultiset.create();
 Collections.addAll(multiset, elements);
 multiset.addAll(ELEMENTS_TO_FILTER_OUT);
 return Multisets.filter(multiset, PREDICATE);
}
origin: wildfly/wildfly

/**
 * Returns a {@code Collector} that accumulates elements into an {@code ImmutableMultiset} whose
 * elements are the result of applying {@code elementFunction} to the inputs, with counts equal to
 * the result of applying {@code countFunction} to the inputs.
 *
 * <p>If the mapped elements contain duplicates (according to {@link Object#equals}), the first
 * occurrence in encounter order appears in the resulting multiset, with count equal to the sum of
 * the outputs of {@code countFunction.applyAsInt(t)} for each {@code t} mapped to that element.
 *
 * @since 22.0
 */
public static <T, E> Collector<T, ?, ImmutableMultiset<E>> toImmutableMultiset(
  Function<? super T, ? extends E> elementFunction, ToIntFunction<? super T> countFunction) {
 checkNotNull(elementFunction);
 checkNotNull(countFunction);
 return Collector.of(
   LinkedHashMultiset::create,
   (multiset, t) ->
     multiset.add(checkNotNull(elementFunction.apply(t)), countFunction.applyAsInt(t)),
   (multiset1, multiset2) -> {
    multiset1.addAll(multiset2);
    return multiset1;
   },
   (Multiset<E> multiset) -> copyFromEntries(multiset.entrySet()));
}
origin: wildfly/wildfly

/**
 * Returns a {@code Collector} that accumulates elements into an {@code ImmutableSortedMultiset}
 * whose elements are the result of applying {@code elementFunction} to the inputs, with counts
 * equal to the result of applying {@code countFunction} to the inputs.
 *
 * <p>If the mapped elements contain duplicates (according to {@code comparator}), the first
 * occurrence in encounter order appears in the resulting multiset, with count equal to the sum of
 * the outputs of {@code countFunction.applyAsInt(t)} for each {@code t} mapped to that element.
 *
 * @since 22.0
 */
public static <T, E> Collector<T, ?, ImmutableSortedMultiset<E>> toImmutableSortedMultiset(
  Comparator<? super E> comparator,
  Function<? super T, ? extends E> elementFunction,
  ToIntFunction<? super T> countFunction) {
 checkNotNull(comparator);
 checkNotNull(elementFunction);
 checkNotNull(countFunction);
 return Collector.of(
   () -> TreeMultiset.create(comparator),
   (multiset, t) ->
     multiset.add(checkNotNull(elementFunction.apply(t)), countFunction.applyAsInt(t)),
   (multiset1, multiset2) -> {
    multiset1.addAll(multiset2);
    return multiset1;
   },
   (Multiset<E> multiset) -> copyOfSortedEntries(comparator, multiset.entrySet()));
}
origin: google/guava

@CollectionFeature.Require(SUPPORTS_ADD)
public void testAddAll_emptyMultiset() {
 assertFalse(getMultiset().addAll(getSubjectGenerator().create()));
 expectUnchanged();
}
origin: google/guava

@CollectionFeature.Require(SUPPORTS_ADD)
public void testAddAll_nonEmptyList() {
 assertTrue(getMultiset().addAll(Arrays.asList(e3(), e4(), e3())));
 expectAdded(e3(), e4(), e3());
}
origin: google/guava

public void testFastAddAllMultiset() {
 final AtomicInteger addCalls = new AtomicInteger();
 Multiset<String> multiset =
   new NoRemoveMultiset<String>() {
    @Override
    public int add(String element, int occurrences) {
     addCalls.incrementAndGet();
     return super.add(element, occurrences);
    }
   };
 ImmutableMultiset<String> adds =
   new ImmutableMultiset.Builder<String>().addCopies("x", 10).build();
 multiset.addAll(adds);
 assertEquals(1, addCalls.get());
}
origin: google/guava

 @CollectionFeature.Require(SUPPORTS_ADD)
 public void testAddAll_nonEmptyMultiset() {
  assertTrue(getMultiset().addAll(getSubjectGenerator().create(e3(), e4(), e3())));
  expectAdded(e3(), e4(), e3());
 }
}
origin: linkedin/indextank-engine

  public static Map<String, Multiset<String>> mergeFacets(Map<String, Multiset<String>> facets1, Map<String, Multiset<String>> facets2) {
    Map<String, Multiset<String>> result = Maps.newHashMap();
    
    Set<String> facets1Cats = facets1.keySet();
    
    for (String category : facets1Cats) {
      Multiset<String> facet1 = HashMultiset.create(facets1.get(category));
      Multiset<String> facet2 = facets2.get(category);
      
      if (facet2 != null) {
        facet1.addAll(facet2);
      }
      result.put(category, facet1);
    }
    
    Set<String> facets2Cats = facets2.keySet();
    
    for (String category : facets2Cats) {
      if (!result.containsKey(category)) {
        result.put(category, HashMultiset.create(facets2.get(category)));
      }
    }
    
    return result;
  }
}
origin: OpenGamma/Strata

@Override
public Set<String> tokens(Iterable<?> iterable) {
 Multiset<String> tokens = HashMultiset.create();
 int index = 0;
 for (Object item : iterable) {
  tokens.add(String.valueOf(index++));
  tokens.addAll(fieldValues(item));
 }
 return tokens.stream()
   .filter(token -> tokens.count(token) == 1)
   .collect(toImmutableSet());
}
origin: com.google.guava/guava-testlib

@CollectionFeature.Require(SUPPORTS_ADD)
public void testAddAll_emptyMultiset() {
 assertFalse(getMultiset().addAll(getSubjectGenerator().create()));
 expectUnchanged();
}
origin: com.google.guava/guava-testlib

@CollectionFeature.Require(SUPPORTS_ADD)
public void testAddAll_nonEmptyList() {
 assertTrue(getMultiset().addAll(Arrays.asList(e3(), e4(), e3())));
 expectAdded(e3(), e4(), e3());
}
origin: com.google.guava/guava-testlib

 @CollectionFeature.Require(SUPPORTS_ADD)
 public void testAddAll_nonEmptyMultiset() {
  assertTrue(getMultiset().addAll(getSubjectGenerator().create(e3(), e4(), e3())));
  expectAdded(e3(), e4(), e3());
 }
}
com.google.common.collectMultisetaddAll

Popular methods of Multiset

  • add
    Adds a number of occurrences of an element to this multiset. Note that if occurrences == 1, this met
  • count
    Returns the number of occurrences of an element in this multiset (thecount of the element). Note tha
  • elementSet
    Returns the set of distinct elements contained in this multiset. The element set is backed by the sa
  • entrySet
    Returns a view of the contents of this multiset, grouped into Multiset.Entry instances, each providi
  • remove
    Removes a number of occurrences of the specified element from this multiset. If the multiset contain
  • size
    Returns the total number of all occurrences of all elements in this multiset. Note: this method does
  • isEmpty
  • clear
  • contains
    Determines whether this multiset contains the specified element.This method refines Collection#conta
  • setCount
    Conditionally sets the count of an element to a new value, as described in #setCount(Object,int), pr
  • iterator
    Elements that occur multiple times in the multiset will appear multiple times in this iterator, thou
  • equals
    Compares the specified object with this multiset for equality. Returns true if the given object is a
  • iterator,
  • equals,
  • containsAll,
  • hashCode,
  • removeAll,
  • toString,
  • stream,
  • forEachEntry,
  • retainAll

Popular in Java

  • Start an intent from android
  • getExternalFilesDir (Context)
  • orElseThrow (Optional)
  • addToBackStack (FragmentTransaction)
  • ObjectMapper (com.fasterxml.jackson.databind)
    This mapper (or, data binder, or codec) provides functionality for converting between Java objects (
  • FileInputStream (java.io)
    A FileInputStream obtains input bytes from a file in a file system. What files are available depends
  • PrintWriter (java.io)
    Prints formatted representations of objects to a text-output stream. This class implements all of th
  • URI (java.net)
    Represents a Uniform Resource Identifier (URI) reference. Aside from some minor deviations noted bel
  • DateFormat (java.text)
    Formats or parses dates and times.This class provides factories for obtaining instances configured f
  • Properties (java.util)
    The Properties class represents a persistent set of properties. The Properties can be saved to a st
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now