guava/src/com/google/common/collect/Multisets.java
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;
  }
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;
  }
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 ; }
An implementation of {@link Multiset#setCount(Object, int)}.
An implementation of {