Tabnine Logo
Multiset.forEachEntry
Code IndexAdd Tabnine to your IDE (free)

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

Best Java code snippets using com.google.common.collect.Multiset.forEachEntry (Showing top 14 results out of 315)

origin: google/guava

/** A specialization of {@code addAllImpl} for when {@code elements} is itself a Multiset. */
private static <E> boolean addAllImpl(Multiset<E> self, Multiset<? extends E> elements) {
 if (elements.isEmpty()) {
  return false;
 }
 elements.forEachEntry(self::add);
 return true;
}
origin: wildfly/wildfly

/** A specialization of {@code addAllImpl} for when {@code elements} is itself a Multiset. */
private static <E> boolean addAllImpl(Multiset<E> self, Multiset<? extends E> elements) {
 if (elements.isEmpty()) {
  return false;
 }
 elements.forEachEntry(self::add);
 return true;
}
origin: google/guava

public void testForEachEntry() {
 List<Entry<E>> expected = new ArrayList<>(getMultiset().entrySet());
 List<Entry<E>> actual = new ArrayList<>();
 getMultiset()
   .forEachEntry((element, count) -> actual.add(Multisets.immutableEntry(element, count)));
 Helpers.assertEqualIgnoringOrder(expected, actual);
}
origin: google/guava

/**
 * Adds each element of {@code elements} to the {@code ImmutableMultiset}.
 *
 * @param elements the {@code Iterable} to add to the {@code ImmutableMultiset}
 * @return this {@code Builder} object
 * @throws NullPointerException if {@code elements} is null or contains a null element
 */
@CanIgnoreReturnValue
@Override
public Builder<E> addAll(Iterable<? extends E> elements) {
 if (elements instanceof Multiset) {
  Multiset<? extends E> multiset = Multisets.cast(elements);
  multiset.forEachEntry((e, n) -> contents.add(checkNotNull(e), n));
 } else {
  super.addAll(elements);
 }
 return this;
}
origin: google/guava

@CollectionFeature.Require(KNOWN_ORDER)
public void testForEachEntryOrdered() {
 List<Entry<E>> expected = new ArrayList<>(getMultiset().entrySet());
 List<Entry<E>> actual = new ArrayList<>();
 getMultiset()
   .forEachEntry((element, count) -> actual.add(Multisets.immutableEntry(element, count)));
 assertEquals(expected, actual);
}
origin: google/guava

public void testForEachEntryDuplicates() {
 initThreeCopies();
 List<Entry<E>> expected = Collections.singletonList(Multisets.immutableEntry(e0(), 3));
 List<Entry<E>> actual = new ArrayList<>();
 getMultiset()
   .forEachEntry((element, count) -> actual.add(Multisets.immutableEntry(element, count)));
 assertEquals(expected, actual);
}
origin: wildfly/wildfly

/**
 * Adds each element of {@code elements} to the {@code ImmutableMultiset}.
 *
 * @param elements the {@code Iterable} to add to the {@code ImmutableMultiset}
 * @return this {@code Builder} object
 * @throws NullPointerException if {@code elements} is null or contains a null element
 */
@CanIgnoreReturnValue
@Override
public Builder<E> addAll(Iterable<? extends E> elements) {
 if (elements instanceof Multiset) {
  Multiset<? extends E> multiset = Multisets.cast(elements);
  multiset.forEachEntry((e, n) -> contents.add(checkNotNull(e), n));
 } else {
  super.addAll(elements);
 }
 return this;
}
origin: org.jboss.eap/wildfly-client-all

/** A specialization of {@code addAllImpl} for when {@code elements} is itself a Multiset. */
private static <E> boolean addAllImpl(Multiset<E> self, Multiset<? extends E> elements) {
 if (elements.isEmpty()) {
  return false;
 }
 elements.forEachEntry(self::add);
 return true;
}
origin: org.kill-bill.billing/killbill-platform-osgi-bundles-logger

/** A specialization of {@code addAllImpl} for when {@code elements} is itself a Multiset. */
private static <E> boolean addAllImpl(Multiset<E> self, Multiset<? extends E> elements) {
 if (elements.isEmpty()) {
  return false;
 }
 elements.forEachEntry(self::add);
 return true;
}
origin: com.google.guava/guava-testlib

public void testForEachEntry() {
 List<Entry<E>> expected = new ArrayList<>(getMultiset().entrySet());
 List<Entry<E>> actual = new ArrayList<>();
 getMultiset()
   .forEachEntry((element, count) -> actual.add(Multisets.immutableEntry(element, count)));
 Helpers.assertEqualIgnoringOrder(expected, actual);
}
origin: org.jboss.eap/wildfly-client-all

/**
 * Adds each element of {@code elements} to the {@code ImmutableMultiset}.
 *
 * @param elements the {@code Iterable} to add to the {@code ImmutableMultiset}
 * @return this {@code Builder} object
 * @throws NullPointerException if {@code elements} is null or contains a null element
 */
@CanIgnoreReturnValue
@Override
public Builder<E> addAll(Iterable<? extends E> elements) {
 if (elements instanceof Multiset) {
  Multiset<? extends E> multiset = Multisets.cast(elements);
  multiset.forEachEntry((e, n) -> contents.add(checkNotNull(e), n));
 } else {
  super.addAll(elements);
 }
 return this;
}
origin: org.kill-bill.billing/killbill-platform-osgi-bundles-logger

/**
 * Adds each element of {@code elements} to the {@code ImmutableMultiset}.
 *
 * @param elements the {@code Iterable} to add to the {@code ImmutableMultiset}
 * @return this {@code Builder} object
 * @throws NullPointerException if {@code elements} is null or contains a null element
 */
@CanIgnoreReturnValue
@Override
public Builder<E> addAll(Iterable<? extends E> elements) {
 if (elements instanceof Multiset) {
  Multiset<? extends E> multiset = Multisets.cast(elements);
  multiset.forEachEntry((e, n) -> contents.add(checkNotNull(e), n));
 } else {
  super.addAll(elements);
 }
 return this;
}
origin: com.google.guava/guava-testlib

@CollectionFeature.Require(KNOWN_ORDER)
public void testForEachEntryOrdered() {
 List<Entry<E>> expected = new ArrayList<>(getMultiset().entrySet());
 List<Entry<E>> actual = new ArrayList<>();
 getMultiset()
   .forEachEntry((element, count) -> actual.add(Multisets.immutableEntry(element, count)));
 assertEquals(expected, actual);
}
origin: com.google.guava/guava-testlib

public void testForEachEntryDuplicates() {
 initThreeCopies();
 List<Entry<E>> expected = Collections.singletonList(Multisets.immutableEntry(e0(), 3));
 List<Entry<E>> actual = new ArrayList<>();
 getMultiset()
   .forEachEntry((element, count) -> actual.add(Multisets.immutableEntry(element, count)));
 assertEquals(expected, actual);
}
com.google.common.collectMultisetforEachEntry

Javadoc

Runs the specified action for each distinct element in this multiset, and the number of occurrences of that element. For some Multiset implementations, this may be more efficient than iterating over the #entrySet() either explicitly or with entrySet().forEach(action).

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
  • addAll
  • 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
  • setCount,
  • iterator,
  • equals,
  • containsAll,
  • hashCode,
  • removeAll,
  • toString,
  • stream,
  • retainAll

Popular in Java

  • Creating JSON documents from java classes using gson
  • getResourceAsStream (ClassLoader)
  • putExtra (Intent)
  • getContentResolver (Context)
  • Pointer (com.sun.jna)
    An abstraction for a native pointer data type. A Pointer instance represents, on the Java side, a na
  • GridBagLayout (java.awt)
    The GridBagLayout class is a flexible layout manager that aligns components vertically and horizonta
  • FileNotFoundException (java.io)
    Thrown when a file specified by a program cannot be found.
  • MessageFormat (java.text)
    Produces concatenated messages in language-neutral way. New code should probably use java.util.Forma
  • Collections (java.util)
    This class consists exclusively of static methods that operate on or return collections. It contains
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now