Package alluxio.collections
Class ConcurrentHashSet<T>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractSet<T>
-
- alluxio.collections.ConcurrentHashSet<T>
-
- Type Parameters:
T
- the type of the set objects
- All Implemented Interfaces:
java.lang.Iterable<T>
,java.util.Collection<T>
,java.util.Set<T>
@ThreadSafe public final class ConcurrentHashSet<T> extends java.util.AbstractSet<T>
A concurrent hash set. This is backed by aConcurrentHashMap
, andSet
operations are translated toConcurrentHashMap
operations.
-
-
Constructor Summary
Constructors Constructor Description ConcurrentHashSet()
Creates a newConcurrentHashSet
.ConcurrentHashSet(int initialCapacity, float loadFactor, int concurrencyLevel)
Creates a newConcurrentHashSet
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(T element)
boolean
addIfAbsent(T element)
Adds an element into the set, if and only if it is not already a part of the set.void
clear()
boolean
contains(java.lang.Object o)
boolean
containsAll(java.util.Collection<?> c)
boolean
isEmpty()
java.util.Iterator<T>
iterator()
boolean
remove(java.lang.Object o)
boolean
removeAll(java.util.Collection<?> c)
boolean
retainAll(java.util.Collection<?> c)
int
size()
java.lang.Object[]
toArray()
<E> E[]
toArray(E[] a)
java.lang.String
toString()
-
-
-
Constructor Detail
-
ConcurrentHashSet
public ConcurrentHashSet()
Creates a newConcurrentHashSet
.
-
ConcurrentHashSet
public ConcurrentHashSet(int initialCapacity, float loadFactor, int concurrencyLevel)
Creates a newConcurrentHashSet
.- Parameters:
initialCapacity
- the initial capacityloadFactor
- the load factor threshold, used to control resizingconcurrencyLevel
- the estimated number of concurrently updating threads
-
-
Method Detail
-
iterator
public java.util.Iterator<T> iterator()
-
size
public int size()
-
add
public boolean add(T element)
-
addIfAbsent
public boolean addIfAbsent(T element)
Adds an element into the set, if and only if it is not already a part of the set.- Parameters:
element
- the element to add into the set- Returns:
- true if this set did not already contain the specified element
-
clear
public void clear()
-
contains
public boolean contains(java.lang.Object o)
-
containsAll
public boolean containsAll(java.util.Collection<?> c)
-
isEmpty
public boolean isEmpty()
-
remove
public boolean remove(java.lang.Object o)
-
removeAll
public boolean removeAll(java.util.Collection<?> c)
-
retainAll
public boolean retainAll(java.util.Collection<?> c)
-
toArray
public java.lang.Object[] toArray()
-
toArray
public <E> E[] toArray(E[] a)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.util.AbstractCollection<T>
-
-