org.jboss.util.collection
E
- the element typepublic class ConcurrentSet<E> extends AbstractSet<E> implements Serializable
Constructor and Description |
---|
ConcurrentSet()
Constructs a new, empty set; the backing ConcurrentHashMap instance has
default initial capacity (16) and load factor (0.75).
|
ConcurrentSet(Collection<? extends E> c)
Constructs a new set containing the elements in the specified
collection.
|
ConcurrentSet(int initialCapacity)
Constructs a new, empty set; the backing ConcurrentHashMap instance has
the specified initial capacity and default load factor, which is
0.75.
|
ConcurrentSet(int initialCapacity,
float loadFactor,
int concurrencyLevel)
Constructs a new, empty set; the backing ConcurrentHashMap instance has
the specified initial capacity and the specified load factor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(E o)
Adds the specified element to this set if it is not already
present.
|
void |
clear()
Removes all of the elements from this set.
|
boolean |
contains(Object o)
Returns true if this set contains the specified element.
|
boolean |
isEmpty()
Returns true if this set contains no elements.
|
Iterator<E> |
iterator()
Returns an iterator over the elements in this set.
|
boolean |
remove(Object o)
Removes the specified element from this set if it is present.
|
int |
size()
Returns the number of elements in this set (its cardinality).
|
String |
toString() |
equals, hashCode, removeAll
addAll, containsAll, retainAll, toArray, toArray
public ConcurrentSet()
public ConcurrentSet(Collection<? extends E> c)
c
- the collection whose elements are to be placed into this set.NullPointerException
- if the specified collection is null.public ConcurrentSet(int initialCapacity, float loadFactor, int concurrencyLevel)
initialCapacity
- the initial capacity. The implementation
performs internal sizing to accommodate this many elements.loadFactor
- the load factor threshold, used to control resizing.
Resizing may be performed when the average number of elements per
bin exceeds this threshold.concurrencyLevel
- the estimated number of concurrently
updating threads. The implementation performs internal sizing
to try to accommodate this many threads.IllegalArgumentException
- if the initial capacity is less
than zero, or if the load factor is nonpositive.public ConcurrentSet(int initialCapacity)
initialCapacity
- the initial capacity of the hash table.IllegalArgumentException
- if the initial capacity is less
than zero.public Iterator<E> iterator()
iterator
in interface Iterable<E>
iterator
in interface Collection<E>
iterator
in interface Set<E>
iterator
in class AbstractCollection<E>
ConcurrentModificationException
public int size()
size
in interface Collection<E>
size
in interface Set<E>
size
in class AbstractCollection<E>
public boolean isEmpty()
isEmpty
in interface Collection<E>
isEmpty
in interface Set<E>
isEmpty
in class AbstractCollection<E>
public boolean contains(Object o)
contains
in interface Collection<E>
contains
in interface Set<E>
contains
in class AbstractCollection<E>
o
- element whose presence in this set is to be tested.public boolean add(E o)
add
in interface Collection<E>
add
in interface Set<E>
add
in class AbstractCollection<E>
o
- element to be added to this set.public boolean remove(Object o)
remove
in interface Collection<E>
remove
in interface Set<E>
remove
in class AbstractCollection<E>
o
- object to be removed from this set, if present.public void clear()
clear
in interface Collection<E>
clear
in interface Set<E>
clear
in class AbstractCollection<E>
public String toString()
toString
in class AbstractCollection<E>
Copyright © 2014 JBoss by Red Hat. All rights reserved.