@CanIgnoreReturnValue
  @Override
  public int add(E element, int occurrences) {
    checkIsE(element);
    checkNonnegative(occurrences, "occurrences");
    if (occurrences == 0) {
      return count(element);
    }
    int index = element.ordinal();
    int oldCount = counts[index];
    long newCount = (long) oldCount + occurrences;
    checkArgument(newCount <= Integer.MAX_VALUE, "too many occurrences: %s", newCount);
    counts[index] = (int) newCount;
    if (oldCount == 0) {
      distinctElements++;
    }
    size += occurrences;
    return oldCount;
  }
@CanIgnoreReturnValue
  @Override
  public int add(E element, int occurrences) {
    checkIsE(element);
    checkNonnegative(occurrences, "occurrences");
    if (occurrences == 0) {
      return count(element);
    }
    int index = element.ordinal();
    int oldCount = counts[index];
    long newCount = (long) oldCount + occurrences;
    checkArgument(newCount <= Integer.MAX_VALUE, "too many occurrences: %s", newCount);
    counts[index] = (int) newCount;
    if (oldCount == 0) {
      distinctElements++;
    }
    size += occurrences;
    return oldCount;
  }
@ CanIgnoreReturnValue @ Override public int add ( E element , int occurrences ) { checkIsE ( element ) ; checkNonnegative ( occurrences , "occurrences" ) ; if ( occurrences == 0 ) { return count ( element ) ; } int index = element . ordinal ( ) ; int oldCount = counts [ index ] ; long newCount = ( long ) oldCount + occurrences ; checkArgument ( newCount <= Integer . MAX_VALUE , "too many occurrences: %s" , newCount ) ; counts [ index ] = ( int ) newCount ; if ( oldCount == 0 ) { distinctElements ++ ; } size += occurrences ; return oldCount ; }
Modification Operations
Modification Operations