|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.commons.collections15.collection.AbstractCollectionDecorator<E>
org.apache.commons.collections15.bag.AbstractBagDecorator<E>
org.apache.commons.collections15.bag.AbstractSortedBagDecorator<E>
org.apache.commons.collections15.bag.UnmodifiableSortedBag<E>
public final class UnmodifiableSortedBag<E>
Decorates another SortedBag to ensure it can't be altered.
| Field Summary |
|---|
| Fields inherited from class org.apache.commons.collections15.collection.AbstractCollectionDecorator |
|---|
collection |
| Method Summary | ||
|---|---|---|
boolean |
add(E object)
(Violation) Adds one copy the specified object to the Bag. |
|
boolean |
add(E object,
int count)
Adds nCopies copies of the specified object to the Bag. |
|
boolean |
addAll(Collection<? extends E> coll)
|
|
void |
clear()
|
|
static
|
decorate(SortedBag<E> 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(E object,
int count)
Removes nCopies copies of the specified object from the Bag. |
|
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. |
|
Set<E> |
uniqueSet()
Returns a Set of unique elements in the Bag. |
|
| Methods inherited from class org.apache.commons.collections15.bag.AbstractSortedBagDecorator |
|---|
comparator, first, getSortedBag, last |
| Methods inherited from class org.apache.commons.collections15.bag.AbstractBagDecorator |
|---|
getBag, getCount |
| Methods inherited from class org.apache.commons.collections15.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.collections15.Bag |
|---|
containsAll, getCount, size |
| Methods inherited from interface java.util.Collection |
|---|
contains, equals, hashCode, isEmpty, toArray, toArray |
| Method Detail |
|---|
public static <E> SortedBag<E> decorate(SortedBag<E> bag)
bag - the bag to decorate, must not be null
IllegalArgumentException - if bag is nullpublic Iterator iterator()
BagIterator over the entire set of members,
including copies due to cardinality. This iterator is fail-fast
and will not tolerate concurrent modifications.
iterator in interface Iterable<E>iterator in interface Collection<E>iterator in interface Bag<E>iterator in class AbstractCollectionDecorator<E>public boolean add(E object)
BagBag.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.
add in interface Collection<E>add in interface Bag<E>add in class AbstractCollectionDecorator<E>object - the object to add
true if the object was not already in the uniqueSetpublic boolean addAll(Collection<? extends E> coll)
addAll in interface Collection<E>addAll in class AbstractCollectionDecorator<E>public void clear()
clear in interface Collection<E>clear in class AbstractCollectionDecorator<E>public boolean remove(Object object)
BagBag.uniqueSet().
According to the Collection.remove(Object) method,
this method should only remove the first occurrence of the
given object, not all occurrences.
remove in interface Collection<E>remove in interface Bag<E>remove in class AbstractCollectionDecorator<E>true if this call changed the collectionpublic boolean removeAll(Collection<?> coll)
Bagcoll 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.
removeAll in interface Collection<E>removeAll in interface Bag<E>removeAll in class AbstractCollectionDecorator<E>coll - the collection to remove
true if this call changed the collectionpublic boolean retainAll(Collection<?> coll)
Bagcoll 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.
retainAll in interface Collection<E>retainAll in interface Bag<E>retainAll in class AbstractCollectionDecorator<E>coll - the collection to retain
true if this call changed the collection
public boolean add(E object,
int count)
BagnCopies copies of the specified object to the 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 nCopies.
add in interface Bag<E>add in class AbstractBagDecorator<E>object - the object to addcount - the number of copies to add
true if the object was not already in the uniqueSet
public boolean remove(E object,
int count)
BagnCopies 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.
remove in interface Bag<E>remove in class AbstractBagDecorator<E>object - the object to removecount - the number of copies to remove
true if this call changed the collectionpublic Set<E> uniqueSet()
BagSet of unique elements in the Bag.
Uniqueness constraints are the same as those in Set.
uniqueSet in interface Bag<E>uniqueSet in class AbstractBagDecorator<E>
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||