|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.beanlib.utils.CollectionUtils
public class CollectionUtils
Collection related utility methods.
Nested Class Summary | |
---|---|
(package private) static class |
CollectionUtils.SynchronizedCollection<E>
Basically cloned from and identification to java.util.Collections.SynchronizedCollection. |
private static class |
CollectionUtils.SynchronizedMap<K,V>
Basically cloned from and identification to java.util.Collections.SynchronizedMap. |
(package private) static class |
CollectionUtils.SynchronizedSet<E>
Basically cloned from and identification to java.util.Collections.SynchronizedSet. |
(package private) static class |
CollectionUtils.SynchronizedSortedMap<K,V>
Basically cloned from and identification to java.util.Collections.SynchronizedSortedMap. |
(package private) static class |
CollectionUtils.SynchronizedSortedRangeMap<T,K,V>
A thread-safe SortedRangeMap. |
Constructor Summary | |
---|---|
private |
CollectionUtils()
|
Method Summary | ||
---|---|---|
static
|
synchronizedSortedRangeMap(SortedRangeMap<T,K,V> m)
Returns a synchronized (thread-safe) sorted range map backed by the specified sorted range map. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
private CollectionUtils()
Method Detail |
---|
public static <T,K,V> SortedRangeMap<T,K,V> synchronizedSortedRangeMap(SortedRangeMap<T,K,V> m)
It is imperative that the user manually synchronize on the returned sorted range map when iterating over any of its collection views, or the collections views of any of its subMap, headMap or tailMap views.
SortedRangeMap m = CollectionUtils.synchronizedSortedRangeMap(new RangeTreeMap()); ... Set s = m.keySet(); // Needn't be in synchronized block ... synchronized(m) { // Synchronizing on m, not s! Iterator i = s.iterator(); // Must be in synchronized block while (i.hasNext()) foo(i.next()); }or:
SortedRangeMap m = CollectionUtils.synchronizedSortedRangeMap(new RangeTreeMap()); SortedMap m2 = m.subMap(foo, bar); ... Set s2 = m2.keySet(); // Needn't be in synchronized block ... synchronized(m) { // Synchronizing on m, not m2 or s2! Iterator i = s.iterator(); // Must be in synchronized block while (i.hasNext()) foo(i.next()); }Failure to follow this advice may result in non-deterministic behavior.
The returned sorted range map will be serializable if the specified sorted range map is serializable.
m
- the sorted range map to be "wrapped" in a synchronized sorted range map.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |