Home | History | Annotate | Download | only in collect

Lines Matching refs:occurrences

69   /** The number of occurrences of each element. */
109 * applies to all occurrences of a given element as a single unit. However, most updates to the
148 * Returns the number of occurrences of {@code element} in this multiset.
151 * @return the nonnegative number of occurrences of the element
203 * Adds a number of occurrences of the specified element to this multiset.
206 * @param occurrences the number of occurrences to add
208 * @throws IllegalArgumentException if {@code occurrences} is negative, or if
211 @Override public int add(E element, int occurrences) {
213 if (occurrences == 0) {
216 checkArgument(occurrences > 0, "Invalid occurrences: %s", occurrences);
221 existingCounter = countMap.putIfAbsent(element, new AtomicInteger(occurrences));
232 int newValue = IntMath.checkedAdd(oldValue, occurrences);
238 throw new IllegalArgumentException("Overflow adding " + occurrences
239 + " occurrences to a count of " + oldValue);
245 AtomicInteger newCounter = new AtomicInteger(occurrences);
259 * Removes a number of occurrences of the specified element from this multiset. If the multiset
260 * contains fewer than this number of occurrences to begin with, all occurrences will be removed.
262 * @param element the element whose occurrences should be removed
263 * @param occurrences the number of occurrences of the element to remove
265 * @throws IllegalArgumentException if {@code occurrences} is negative
269 * if occurrences == 0. This satisfies both NullPointerTester and
276 @Override public int remove(@Nullable Object element, int occurrences) {
277 if (occurrences == 0) {
280 checkArgument(occurrences > 0, "Invalid occurrences: %s", occurrences);
289 int newValue = Math.max(0, oldValue - occurrences);
305 * Removes exactly the specified number of occurrences of {@code element}, or makes no
309 * element count is smaller than {@code occurrences}.
312 * @param occurrences the number of occurrences of {@code element} to remove
313 * @return {@code true} if the removal was possible (including if {@code occurrences} is zero)
315 public boolean removeExactly(@Nullable Object element, int occurrences) {
316 if (occurrences == 0) {
319 checkArgument(occurrences > 0, "Invalid occurrences: %s", occurrences);
327 if (oldValue < occurrences) {
330 int newValue = oldValue - occurrences;
343 * Adds or removes occurrences of {@code element} such that the {@link #count} of the
394 * Sets the number of occurrences of {@code element} to {@code newCount}, but only if