Home | History | Annotate | Download | only in collect

Lines Matching refs:element

55   /** The number of occurrences of each element. */
111 * Returns the number of occurrences of {@code element} in this multiset.
113 * @param element the element to look for
114 * @return the nonnegative number of occurrences of the element
116 @Override public int count(@Nullable Object element) {
118 return unbox(countMap.get(element));
161 E element = entry.getElement();
163 list.add(element);
172 * Adds a number of occurrences of the specified element to this multiset.
174 * @param element the element to add
176 * @return the previous count of the element before the operation; possibly
181 @Override public int add(E element, int occurrences) {
183 return count(element);
188 int current = count(element);
190 if (countMap.putIfAbsent(element, occurrences) == null) {
198 if (countMap.replace(element, current, next)) {
207 * Removes a number of occurrences of the specified element from this
211 * @param element the element whose occurrences should be removed
212 * @param occurrences the number of occurrences of the element to remove
213 * @return the count of the element before the operation; possibly zero
216 @Override public int remove(@Nullable Object element, int occurrences) {
218 return count(element);
223 int current = count(element);
228 if (countMap.remove(element, current)) {
234 E casted = (E) element;
245 * Removes <b>all</b> occurrences of the specified element from this multiset.
249 * @param element the element whose occurrences should all be removed
252 private int removeAllOccurrences(@Nullable Object element) {
254 return unbox(countMap.remove(element));
263 * Removes exactly the specified number of occurrences of {@code element}, or
267 * when the element count is smaller than {@code occurrences}.
269 * @param element the element to remove
270 * @param occurrences the number of occurrences of {@code element} to remove
274 public boolean removeExactly(@Nullable Object element, int occurrences) {
281 int current = count(element);
286 if (countMap.remove(element, occurrences)) {
291 E casted = (E) element;
301 * Adds or removes occurrences of {@code element} such that the {@link #count}
302 * of the element becomes {@code count}.
304 * @return the count of {@code element} in the multiset before this call
307 @Override public int setCount(E element, int count) {
310 ? removeAllOccurrences(element)
311 : unbox(countMap.put(element, count));
315 * Sets the number of occurrences of {@code element} to {@code newCount}, but
316 * only if the count is currently {@code oldCount}. If {@code element} does
327 @Override public boolean setCount(E element, int oldCount, int newCount) {
332 // No change to make, but must return true if the element is not present
333 return !countMap.containsKey(element);
335 return countMap.remove(element, oldCount);
339 return countMap.putIfAbsent(element, newCount) == null;
341 return countMap.replace(element, oldCount, newCount);
386 Object element = entry.getElement();
388 return entryCount > 0 && count(element) == entryCount;
441 Object element = entry.getElement();
443 return countMap.remove(element, entryCount);
468 * @serialData the number of distinct elements, the first element, its count,
469 * the second element, its count, and so on