|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.commons.collections.BagUtils
Provides utility methods and decorators for Bag
and SortedBag
instances.
Method Summary | |
static Bag |
predicatedBag(Bag bag,
Predicate predicate)
Returns a predicated bag backed by the given bag. |
static SortedBag |
predicatedSortedBag(SortedBag bag,
Predicate predicate)
Returns a predicated sorted bag backed by the given sorted bag. |
static Bag |
synchronizedBag(Bag bag)
Returns a synchronized (thread-safe) bag backed by the given bag. |
static SortedBag |
synchronizedSortedBag(SortedBag bag)
Returns a synchronized (thread-safe) sorted bag backed by the given sorted bag. |
static Bag |
unmodifiableBag(Bag bag)
Returns an unmodifiable view of the given bag. |
static SortedBag |
unmodifiableSortedBag(SortedBag bag)
Returns an unmodifiable view of the given sorted bag. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
public static Bag predicatedBag(Bag bag, Predicate predicate)
bag
- the bag to predicate, must not be nullpredicate
- the predicate for the bag, must not be null
java.lang.IllegalArgumentException
- if the Bag or Predicate is nullpublic static Bag unmodifiableBag(Bag bag)
UnsupportedOperationException
.
bag
- the bag whose unmodifiable view is to be returned, must not be null
java.lang.IllegalArgumentException
- if the Bag is nullpublic static Bag synchronizedBag(Bag bag)
It is imperative that the user manually synchronize on the returned bag when iterating over it:
Bag bag = BagUtils.synchronizedBag(new HashBag()); ... synchronized(bag) { Iterator i = bag.iterator(); // Must be in synchronized block while (i.hasNext()) foo(i.next()); } }Failure to follow this advice may result in non-deterministic behavior.
bag
- the bag to synchronize, must not be null
java.lang.IllegalArgumentException
- if the Bag is nullpublic static SortedBag predicatedSortedBag(SortedBag bag, Predicate predicate)
bag
- the sorted bag to predicate, must not be nullpredicate
- the predicate for the bag, must not be null
java.lang.IllegalArgumentException
- if the SortedBag or Predicate is nullpublic static SortedBag unmodifiableSortedBag(SortedBag bag)
UnsupportedOperationException
.
bag
- the bag whose unmodifiable view is to be returned, must not be null
java.lang.IllegalArgumentException
- if the SortedBag is nullpublic static SortedBag synchronizedSortedBag(SortedBag bag)
It is imperative that the user manually synchronize on the returned bag when iterating over it:
SortedBag bag = BagUtils.synchronizedSortedBag(new TreeBag()); ... synchronized(bag) { Iterator i = bag.iterator(); // Must be in synchronized block while (i.hasNext()) foo(i.next()); } }Failure to follow this advice may result in non-deterministic behavior.
bag
- the bag to synchronize, must not be null
java.lang.IllegalArgumentException
- if the SortedBag is null
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |