|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.devexperts.util.AbstractConcurrentSet<V>
com.devexperts.util.IndexedSet<K,V>
com.devexperts.util.SynchronizedIndexedSet<K,V>
public class SynchronizedIndexedSet<K,V>
A synchronized thread-safe version of IndexedSet
class.
It provides following benefits over standard IndexedSet
:
Note that SynchronizedIndexedSet can be wrapped by IndexedMap
to create what can be considered a SynchronizedIndexedMap.
Constructor Summary | |
---|---|
SynchronizedIndexedSet()
Creates new empty set with default indexer Indexer.DEFAULT and default initial capacity. |
|
SynchronizedIndexedSet(Collection<V> c)
Creates a new set containing the elements in the specified collection. |
|
SynchronizedIndexedSet(Indexer<K,? super V> indexer)
Creates new empty set with specified indexer and default initial capacity. |
|
SynchronizedIndexedSet(Indexer<K,? super V> indexer,
Collection<? extends V> c)
Creates a new set with specified indexer containing the elements in the specified collection. |
|
SynchronizedIndexedSet(Indexer<K,? super V> indexer,
int initial_capacity)
Creates new empty set with specified indexer and specified initial capacity. |
|
SynchronizedIndexedSet(int initial_capacity)
Creates new empty set with default indexer Indexer.DEFAULT and specified initial capacity. |
Method Summary | ||
---|---|---|
void |
clear()
Removes all elements from this set. |
|
SynchronizedIndexedSet<K,V> |
clone()
Returns a shallow copy of this set - the values themselves are not cloned. |
|
void |
ensureCapacity(int capacity)
Increases the capacity of this set instance, if necessary, to ensure that it can hold at least the number of elements specified by the capacity argument. |
|
IndexedSetStats |
getStats()
Returns static structure statistics of this set. |
|
static
|
of(V... objs)
Creates a new set with default indexer containing specified elements. |
|
V |
put(V value)
Puts specified element into this set and returns previous element that matches specified one. |
|
V |
putIfAbsentAndGet(V value)
Puts specified element into this set if it is absent and returns current element in the set that matches specified one. |
|
V |
removeKey(K key)
Removes the element from this set which matches specified key if it is present and returns removed element or null if none were found. |
|
V |
removeKey(long key)
Removes the element from this set which matches specified key if it is present and returns removed element or null if none were found. |
|
V |
removeValue(V value)
Removes the element from this set which matches specified value if it is present and returns removed element or null if none were found. |
|
void |
trimToSize()
Trims the capacity of this set instance to be the set's current size. |
Methods inherited from class com.devexperts.util.IndexedSet |
---|
add, concurrentIterator, contains, containsKey, containsKey, containsValue, entryIterator, getByKey, getByKey, getByValue, getIndexer, iterator, keyIterator, remove, size, toArray, toArray |
Methods inherited from class com.devexperts.util.AbstractConcurrentSet |
---|
addAll, containsAll, equals, hashCode, isEmpty, removeAll, retainAll, toString |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public SynchronizedIndexedSet()
Indexer.DEFAULT
and default initial capacity.
public SynchronizedIndexedSet(int initial_capacity)
Indexer.DEFAULT
and specified initial capacity.
public SynchronizedIndexedSet(Indexer<K,? super V> indexer)
public SynchronizedIndexedSet(Indexer<K,? super V> indexer, int initial_capacity)
public SynchronizedIndexedSet(Collection<V> c)
IndexedSet
, then new indexed set uses same indexer,
otherwise it uses default indexer Indexer.DEFAULT
.
public SynchronizedIndexedSet(Indexer<K,? super V> indexer, Collection<? extends V> c)
Method Detail |
---|
public static <V> SynchronizedIndexedSet<V,V> of(V... objs)
public SynchronizedIndexedSet<K,V> clone()
clone
in class IndexedSet<K,V>
public void ensureCapacity(int capacity)
ensureCapacity
in class IndexedSet<K,V>
public void trimToSize()
trimToSize
in class IndexedSet<K,V>
public void clear()
clear
in interface Collection<V>
clear
in interface Set<V>
clear
in class IndexedSet<K,V>
public IndexedSetStats getStats()
getStats
in class IndexedSet<K,V>
public V put(V value)
put
in class IndexedSet<K,V>
public V putIfAbsentAndGet(V value)
if (set.containsValue(value)) { return set.getByValue(value); } else { set.put(value); return value; }except that the action is performed atomically if it is properly synchronized.
Note, that unlike ConcurrentMap.putIfAbsent(K, V)
,
this method returns specified value (not null) if the value was absent.
putIfAbsentAndGet
in class IndexedSet<K,V>
public V removeValue(V value)
removeValue
in class IndexedSet<K,V>
public V removeKey(K key)
removeKey
in class IndexedSet<K,V>
public V removeKey(long key)
removeKey
in class IndexedSet<K,V>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |