org.apache.commons.collections
Class BagUtils.PredicatedBag
java.lang.Object
org.apache.commons.collections.CollectionUtils.CollectionWrapper
org.apache.commons.collections.CollectionUtils.PredicatedCollection
org.apache.commons.collections.BagUtils.PredicatedBag
- All Implemented Interfaces:
- Bag, java.util.Collection
- Direct Known Subclasses:
- BagUtils.PredicatedSortedBag
- Enclosing class:
- BagUtils
- static class BagUtils.PredicatedBag
- extends CollectionUtils.PredicatedCollection
- implements Bag
| Method Summary |
boolean |
add(java.lang.Object o)
(Violation) Add the given object to the bag and keep a count. |
boolean |
add(java.lang.Object o, int count)
Add i copies of the given object to the bag and keep a count. |
boolean |
addAll(java.util.Collection c2)
|
void |
clear()
|
boolean |
contains(java.lang.Object o)
|
boolean |
containsAll(java.util.Collection c2)
(Violation) Returns true if the bag contains all elements in the given collection, respecting cardinality. |
boolean |
equals(java.lang.Object o)
|
private Bag |
getBag()
|
int |
getCount(java.lang.Object o)
Return the number of occurrences (cardinality) of the given object currently in the bag. |
int |
hashCode()
|
boolean |
isEmpty()
|
java.util.Iterator |
iterator()
Returns an Iterator over the entire set of members, including copies due to cardinality. |
boolean |
remove(java.lang.Object o)
(Violation) Remove all occurrences of the given object from the bag, and do not represent the object in the #uniqueSet(). |
boolean |
remove(java.lang.Object o, int count)
Remove the given number of occurrences from the bag. |
boolean |
removeAll(java.util.Collection c2)
(Violation) Remove all elements represented in the given collection, respecting cardinality. |
boolean |
retainAll(java.util.Collection c2)
(Violation) Remove any members of the bag that are not in the given collection, respecting cardinality. |
int |
size()
Returns the total number of items in the bag across all types. |
java.lang.Object[] |
toArray()
|
java.lang.Object[] |
toArray(java.lang.Object[] o)
|
java.lang.String |
toString()
|
java.util.Set |
uniqueSet()
The Set of unique members that represent all members in the bag. |
protected void |
validate(java.lang.Object o)
|
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Collection |
addAll, clear, contains, equals, hashCode, isEmpty, toArray, toArray |
predicate
protected final Predicate predicate
-
collection
protected final java.util.Collection collection
-
BagUtils.PredicatedBag
public BagUtils.PredicatedBag(Bag b,
Predicate p)
add
public boolean add(java.lang.Object o,
int count)
- Description copied from interface:
Bag
-
Add
i copies of the given object to the bag and keep a count.
-
- Specified by:
add in interface Bag
-
- Returns:
true if the object was not already in the uniqueSet
- See Also:
Bag.add(Object), Bag.getCount(Object)
remove
public boolean remove(java.lang.Object o,
int count)
- Description copied from interface:
Bag
-
Remove the given number of occurrences from the bag. If the bag contains
i occurrences or less, the item will be removed from the Bag.uniqueSet().
-
- Specified by:
remove in interface Bag
-
- Returns:
true if this call changed the collection
- See Also:
Bag.getCount(Object), Bag.remove(Object)
uniqueSet
public java.util.Set uniqueSet()
- Description copied from interface:
Bag
-
The
Set of unique members that represent all members in the bag. Uniqueness constraints are the same as those in Set.
-
- Specified by:
uniqueSet in interface Bag
-
getCount
public int getCount(java.lang.Object o)
- Description copied from interface:
Bag
-
Return the number of occurrences (cardinality) of the given object currently in the bag. If the object does not exist in the bag, return 0.
-
- Specified by:
getCount in interface Bag
-
getBag
private Bag getBag()
-
-
add
public boolean add(java.lang.Object o)
-
- Specified by:
add in interface java.util.Collection
- Overrides:
add in class CollectionUtils.CollectionWrapper
-
addAll
public boolean addAll(java.util.Collection c2)
-
- Specified by:
addAll in interface java.util.Collection
- Overrides:
addAll in class CollectionUtils.CollectionWrapper
-
validate
protected void validate(java.lang.Object o)
-
size
public int size()
-
- Specified by:
size in interface java.util.Collection
-
isEmpty
public boolean isEmpty()
-
- Specified by:
isEmpty in interface java.util.Collection
-
contains
public boolean contains(java.lang.Object o)
-
- Specified by:
contains in interface java.util.Collection
-
iterator
public java.util.Iterator iterator()
-
- Specified by:
iterator in interface java.util.Collection
-
toArray
public java.lang.Object[] toArray()
-
- Specified by:
toArray in interface java.util.Collection
-
toArray
public java.lang.Object[] toArray(java.lang.Object[] o)
-
- Specified by:
toArray in interface java.util.Collection
-
remove
public boolean remove(java.lang.Object o)
-
- Specified by:
remove in interface java.util.Collection
-
containsAll
public boolean containsAll(java.util.Collection c2)
-
- Specified by:
containsAll in interface java.util.Collection
-
removeAll
public boolean removeAll(java.util.Collection c2)
-
- Specified by:
removeAll in interface java.util.Collection
-
retainAll
public boolean retainAll(java.util.Collection c2)
-
- Specified by:
retainAll in interface java.util.Collection
-
clear
public void clear()
-
- Specified by:
clear in interface java.util.Collection
-
equals
public boolean equals(java.lang.Object o)
-
- Specified by:
equals in interface java.util.Collection
-
hashCode
public int hashCode()
-
- Specified by:
hashCode in interface java.util.Collection
-
toString
public java.lang.String toString()
-
-
Please see keelframework.org for information about new Keel releases.