Codota Logo
Multiset.forEachEntry
Code IndexAdd Codota 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)

  • Common ways to obtain Multiset
private void myMethod () {
Multiset m =
  • Codota IconMultimap fromMultimap;fromMultimap.keys()
  • Codota Iconnew Keys()
  • Codota Iconnew Multimaps.Keys<K, V>(this)
  • Smart code suggestions by Codota
}
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

  • Parsing JSON documents to java classes using gson
  • requestLocationUpdates (LocationManager)
  • setRequestProperty (URLConnection)
    Sets the general request property. If a property with the key already exists, overwrite its value wi
  • scheduleAtFixedRate (ScheduledExecutorService)
    Creates and executes a periodic action that becomes enabled first after the given initial delay, and
  • Menu (java.awt)
  • BufferedInputStream (java.io)
    Wraps an existing InputStream and buffers the input. Expensive interaction with the underlying input
  • OutputStream (java.io)
    A writable sink for bytes.Most clients will use output streams that write data to the file system (
  • Thread (java.lang)
    A thread is a thread of execution in a program. The Java Virtual Machine allows an application to ha
  • NumberFormat (java.text)
    The abstract base class for all number formats. This class provides the interface for formatting and
  • BasicDataSource (org.apache.commons.dbcp)
    Basic implementation of javax.sql.DataSource that is configured via JavaBeans properties. This is no
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