java.lang.Object | ||
↳ | org.apache.commons.collections.collection.AbstractCollectionDecorator | |
↳ | org.apache.commons.collections.bag.AbstractBagDecorator |
Known Direct Subclasses |
Known Indirect Subclasses |
Decorates another Bag
to provide additional behaviour.
Methods are forwarded directly to the decorated bag.
[Expand]
Inherited Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.apache.commons.collections.collection.AbstractCollectionDecorator
|
Protected Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Constructor only used in deserialization, do not use otherwise.
| |||||||||||
Constructor that wraps (not copies).
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Adds
nCopies copies of the specified object to the Bag. | |||||||||||
Returns the number of occurrences (cardinality) of the given
object currently in the bag.
| |||||||||||
Removes
nCopies copies of the specified object from the Bag. | |||||||||||
Returns a
Set of unique elements in the Bag. |
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Gets the bag being decorated.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.apache.commons.collections.collection.AbstractCollectionDecorator
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
java.lang.Iterable
| |||||||||||
From interface
java.util.Collection
| |||||||||||
From interface
org.apache.commons.collections.Bag
|
Constructor only used in deserialization, do not use otherwise.
Constructor that wraps (not copies).
bag | the bag to decorate, must not be null |
---|
IllegalArgumentException | if list is null |
---|
Adds nCopies
copies of the specified object to the Bag.
If the object is already in the uniqueSet()
then increment its
count as reported by getCount(Object)
. Otherwise add it to the
uniqueSet()
and report its count as nCopies
.
object | the object to add |
---|---|
count | the number of copies to add |
true
if the object was not already in the uniqueSet
Returns the number of occurrences (cardinality) of the given object currently in the bag. If the object does not exist in the bag, return 0.
object | the object to search for |
---|
Removes nCopies
copies of the specified object from the Bag.
If the number of copies to remove is greater than the actual number of copies in the Bag, no error is thrown.
object | the object to remove |
---|---|
count | the number of copies to remove |
true
if this call changed the collection