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

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

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

origin: google/guava

@Override
public int remove(Object o, int n) {
 synchronized (mutex) {
  return delegate().remove(o, n);
 }
}
origin: google/guava

@Override
public N removeInEdge(E edge, boolean isSelfLoop) {
 N node = super.removeInEdge(edge, isSelfLoop);
 Multiset<N> predecessors = getReference(predecessorsReference);
 if (predecessors != null) {
  checkState(predecessors.remove(node));
 }
 return node;
}
origin: google/guava

@Override
public N removeOutEdge(E edge) {
 N node = super.removeOutEdge(edge);
 Multiset<N> adjacentNodes = getReference(adjacentNodesReference);
 if (adjacentNodes != null) {
  checkState(adjacentNodes.remove(node));
 }
 return node;
}
origin: google/guava

@Override
public N removeOutEdge(E edge) {
 N node = super.removeOutEdge(edge);
 Multiset<N> successors = getReference(successorsReference);
 if (successors != null) {
  checkState(successors.remove(node));
 }
 return node;
}
origin: google/guava

/** An implementation of {@link Multiset#setCount(Object, int)}. */
static <E> int setCountImpl(Multiset<E> self, E element, int count) {
 checkNonnegative(count, "count");
 int oldCount = self.count(element);
 int delta = count - oldCount;
 if (delta > 0) {
  self.add(element, delta);
 } else if (delta < 0) {
  self.remove(element, -delta);
 }
 return oldCount;
}
origin: google/guava

 @Override
 public void remove() {
  checkRemove(canRemove);
  if (totalCount == 1) {
   entryIterator.remove();
  } else {
   multiset.remove(currentEntry.getElement());
  }
  totalCount--;
  canRemove = false;
 }
}
origin: google/guava

@CanIgnoreReturnValue
@Override
public int remove(Object element, int occurrences) {
 return delegate().remove(element, occurrences);
}
origin: google/guava

@CollectionFeature.Require(value = SUPPORTS_REMOVE, absent = ALLOWS_NULL_QUERIES)
public void testRemove_nullForbidden() {
 try {
  getMultiset().remove(null, 2);
  fail("Expected NullPointerException");
 } catch (NullPointerException expected) {
 }
}
origin: google/guava

@MapFeature.Require(SUPPORTS_REMOVE)
public void testKeysRemove() {
 int original = multimap().keys().remove(k0(), 1);
 assertEquals(Math.max(original - 1, 0), multimap().get(k0()).size());
}
origin: google/guava

@CollectionFeature.Require(absent = SUPPORTS_REMOVE)
public void testRemoveUnsupported() {
 try {
  getMultiset().remove(e0(), 2);
  fail("Expected UnsupportedOperationException");
 } catch (UnsupportedOperationException expected) {
 }
}
origin: google/guava

@CollectionFeature.Require(SUPPORTS_REMOVE)
public void testRemove_occurrences_negative() {
 try {
  getMultiset().remove(e0(), -1);
  fail("multiset.remove(E, -1) didn't throw an exception");
 } catch (IllegalArgumentException required) {
 }
}
origin: google/guava

@CollectionSize.Require(absent = ZERO)
public void testEquals_differentElements() {
 Multiset<E> other = HashMultiset.create(getSampleElements());
 other.remove(e0());
 other.add(e3());
 assertFalse("multiset equals a multiset with different elements", getMultiset().equals(other));
}
origin: google/guava

@CollectionFeature.Require(absent = SUPPORTS_REMOVE)
public void testRemove_occurrences_unsupported_absent() {
 // notice: we don't care whether it succeeds, or fails with UOE
 try {
  assertEquals(
    "multiset.remove(absent, 2) didn't return 0 or throw an exception",
    0,
    getMultiset().remove(e3(), 2));
 } catch (UnsupportedOperationException ok) {
 }
}
origin: google/guava

 @Override
 public int remove(@Nullable Object element, int occurrences) {
  checkNonnegative(occurrences, "occurrences");
  if (occurrences == 0) {
   return count(element);
  } else {
   return contains(element) ? unfiltered.remove(element, occurrences) : 0;
  }
 }
}
origin: google/guava

@CollectionFeature.Require(SUPPORTS_REMOVE)
public void testRemoveNegative() {
 try {
  getMultiset().remove(e0(), -1);
  fail("Expected IllegalArgumentException");
 } catch (IllegalArgumentException expected) {
 }
 expectUnchanged();
}
origin: google/guava

public void testLinkedKeys() {
 Multimap<String, Integer> map = create();
 map.put("bar", 1);
 map.put("foo", 2);
 map.put("bar", 3);
 map.put("bar", 4);
 assertEquals("[bar=1, foo=2, bar=3, bar=4]", map.entries().toString());
 assertThat(map.keys()).containsExactly("bar", "foo", "bar", "bar").inOrder();
 map.keys().remove("bar"); // bar is no longer the first key!
 assertEquals("{foo=[2], bar=[3, 4]}", map.toString());
}
origin: google/guava

@CollectionFeature.Require(SUPPORTS_REMOVE)
public void testRemove_occurrences_0() {
 int oldCount = getMultiset().count(e0());
 assertEquals(
   "multiset.remove(E, 0) didn't return the old count",
   oldCount,
   getMultiset().remove(e0(), 0));
}
origin: google/guava

public void testRemoveUnsupported() {
 Multiset<String> multiset = new NoRemoveMultiset<>();
 multiset.add("a");
 try {
  multiset.remove("a");
  fail();
 } catch (UnsupportedOperationException expected) {
 }
 assertTrue(multiset.contains("a"));
}
origin: google/guava

@CollectionFeature.Require(SUPPORTS_REMOVE)
public void testRemoveZeroNoOp() {
 int originalCount = getMultiset().count(e0());
 assertEquals("old count", originalCount, getMultiset().remove(e0(), 0));
 expectUnchanged();
}
origin: google/guava

@CollectionSize.Require(absent = ZERO)
@CollectionFeature.Require(SUPPORTS_REMOVE)
public void testRemove_occurrences_present() {
 assertEquals(
   "multiset.remove(present, 2) didn't return the old count",
   1,
   getMultiset().remove(e0(), 2));
 assertFalse(
   "multiset contains present after multiset.remove(present, 2)",
   getMultiset().contains(e0()));
 assertEquals(0, getMultiset().count(e0()));
}
com.google.common.collectMultisetremove

Javadoc

Removes a single occurrence of the specified element from this multiset, if present.

This method refines Collection#remove to further specify that it may not throw an exception in response to element being null or of the wrong type.

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
  • 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
  • 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

  • Making http requests using okhttp
  • getContentResolver (Context)
  • setScale (BigDecimal)
  • getApplicationContext (Context)
  • ObjectMapper (com.fasterxml.jackson.databind)
    ObjectMapper provides functionality for reading and writing JSON, either to and from basic POJOs (Pl
  • FileOutputStream (java.io)
    An output stream that writes bytes to a file. If the output file exists, it can be replaced or appen
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • NumberFormat (java.text)
    The abstract base class for all number formats. This class provides the interface for formatting and
  • JComboBox (javax.swing)
  • SAXParseException (org.xml.sax)
    Encapsulate an XML parse error or warning.> This module, both source code and documentation, is in t
  • 14 Best Plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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