@Override public boolean add(final E object, final int count) { synchronized (lock) { return getBag().add(object, count); } }
@Override public boolean add(final E object, final int count) { return decorated().add(object, count); }
/** * <i>(Change)</i> * Adds <code>count</code> copies of the specified object to the Bag. * <p> * Since this method always increases the size of the bag, it * will always return <code>true</code>. * * @param object the object to add * @param count the number of copies to add * @return <code>true</code>, always */ @Override public boolean add(final E object, final int count) { decorated().add(object, count); return true; }
@Override public boolean add(final E object, final int count) { validate(object); return decorated().add(object, count); }
@Override public boolean add(final E object, final int nCopies) { return getBag().add(transform(object), nCopies); }
/** * Remove any members of the bag that are not in the given bag, respecting * cardinality. * @see #retainAll(Collection) * * @param other the bag to retain * @return <code>true</code> if this call changed the collection */ boolean retainAll(final Bag<?> other) { boolean result = false; final Bag<E> excess = new HashBag<E>(); final Iterator<E> i = uniqueSet().iterator(); while (i.hasNext()) { final E current = i.next(); final int myCount = getCount(current); final int otherCount = other.getCount(current); if (1 <= otherCount && otherCount <= myCount) { excess.add(current, myCount - otherCount); } else { excess.add(current, myCount); } } if (!excess.isEmpty()) { result = removeAll(excess); } return result; }