|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.commons.collections.collection.AbstractCollectionDecorator | +--org.apache.commons.collections.bag.AbstractBagDecorator | +--org.apache.commons.collections.bag.AbstractSortedBagDecorator | +--org.apache.commons.collections.bag.UnmodifiableSortedBag
Decorates another SortedBag
to ensure it can't be altered.
Fields inherited from class org.apache.commons.collections.collection.AbstractCollectionDecorator |
collection |
Method Summary | |
boolean |
add(Object object)
(Violation) Adds one copy the specified object to the Bag. |
boolean |
addAll(Collection coll)
|
void |
clear()
|
static SortedBag |
decorate(SortedBag bag)
Factory method to create an unmodifiable bag. |
Iterator |
iterator()
Returns an Iterator over the entire set of members,
including copies due to cardinality. |
boolean |
remove(Object object)
(Violation) Removes all occurrences of the given object from the bag. |
boolean |
removeAll(Collection coll)
(Violation) Remove all elements represented in the given collection, respecting cardinality. |
boolean |
retainAll(Collection coll)
(Violation) Remove any members of the bag that are not in the given collection, respecting cardinality. |
Methods inherited from class org.apache.commons.collections.bag.AbstractSortedBagDecorator |
comparator, first, getSortedBag, last |
Methods inherited from class org.apache.commons.collections.bag.AbstractBagDecorator |
add, getBag, getCount, remove, uniqueSet |
Methods inherited from class org.apache.commons.collections.collection.AbstractCollectionDecorator |
contains, containsAll, equals, getCollection, hashCode, isEmpty, size, toArray, toArray, toString |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.apache.commons.collections.Bag |
add, containsAll, getCount, remove, size, uniqueSet |
Methods inherited from interface java.util.Collection |
contains, equals, hashCode, isEmpty, toArray, toArray |
Method Detail |
public static SortedBag decorate(SortedBag bag)
bag
- the bag to decorate, must not be nullIllegalArgumentException
- if bag is nullpublic Iterator iterator()
Bag
Iterator
over the entire set of members,
including copies due to cardinality. This iterator is fail-fast
and will not tolerate concurrent modifications.iterator
in class AbstractCollectionDecorator
org.apache.commons.collections.Bag
public boolean add(Object object)
Bag
If the object is already in the Bag.uniqueSet()
then increment its
count as reported by Bag.getCount(Object)
. Otherwise add it to the
Bag.uniqueSet()
and report its count as 1.
Since this method always increases the size of the bag,
according to the Collection.add(Object)
contract, it
should always return true
. Since it sometimes returns
false
, this method violates the contract. A future
version of this method will comply by always returning true
.
add
in class AbstractCollectionDecorator
org.apache.commons.collections.Bag
object
- the object to addtrue
if the object was not already in the uniqueSet
public boolean addAll(Collection coll)
addAll
in class AbstractCollectionDecorator
public void clear()
clear
in class AbstractCollectionDecorator
public boolean remove(Object object)
Bag
This will also remove the object from the Bag.uniqueSet()
.
According to the Collection.remove(Object)
method,
this method should only remove the first occurrence of the
given object, not all occurrences. A future version of this
method will comply with the contract by only removing one occurrence
of the given object.
remove
in class AbstractCollectionDecorator
org.apache.commons.collections.Bag
true
if this call changed the collectionpublic boolean removeAll(Collection coll)
Bag
coll
contains n
copies of a given object,
the bag will have n
fewer copies, assuming the bag
had at least n
copies to begin with.
The Collection.removeAll(Collection)
method specifies
that cardinality should not be respected; this method should
remove all occurrences of every object contained in the
given collection. A future version of this method will comply
with that contract.
removeAll
in class AbstractCollectionDecorator
org.apache.commons.collections.Bag
coll
- the collection to removetrue
if this call changed the collectionpublic boolean retainAll(Collection coll)
Bag
coll
contains n
copies of a
given object and the bag has m > n
copies, then
delete m - n
copies from the bag. In addition, if
e
is an object in the bag but
!coll.contains(e)
, then remove e
and any
of its copies.
The Collection.retainAll(Collection)
method specifies
that cardinality should not be respected; this method should
keep all occurrences of every object contained in the
given collection. A future version of this method will comply
with that contract.
retainAll
in class AbstractCollectionDecorator
org.apache.commons.collections.Bag
coll
- the collection to retaintrue
if this call changed the collection
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |