code: 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;
    }
docs: An implementation of {@link Multiset#setCount(Object, int)}.