Package com.cedarsoftware.util
Class ConcurrentSet<T>
java.lang.Object
com.cedarsoftware.util.ConcurrentSet<T>
- All Implemented Interfaces:
Iterable<T>
,Collection<T>
,Set<T>
ConcurrentSet provides a Set that is thread-safe and usable in highly concurrent environments.
It supports adding and handling null elements by using a sentinel (NULL_ITEM).
- Author:
- John DeRegnaucourt
Copyright Cedar Software LLC
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
License
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a new empty ConcurrentSet.ConcurrentSet
(Collection<T> col) Create a new ConcurrentSet instance with data from the passed-in Collection.ConcurrentSet
(Set<T> set) Create a new ConcurrentSet instance by wrapping an existing Set. -
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
addAll
(Collection<? extends T> col) void
clear()
boolean
boolean
containsAll
(Collection<?> col) boolean
int
hashCode()
boolean
isEmpty()
iterator()
boolean
boolean
removeAll
(Collection<?> col) boolean
retainAll
(Collection<?> col) int
size()
Object[]
toArray()
<T1> T1[]
toArray
(T1[] a) toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream
Methods inherited from interface java.util.Set
spliterator
-
Constructor Details
-
ConcurrentSet
public ConcurrentSet()Create a new empty ConcurrentSet. -
ConcurrentSet
Create a new ConcurrentSet instance with data from the passed-in Collection. This data is populated into the internal set with nulls replaced by NULL_ITEM.- Parameters:
col
- Collection to supply initial elements.
-
ConcurrentSet
Create a new ConcurrentSet instance by wrapping an existing Set. Nulls in the existing set are replaced by NULL_ITEM.- Parameters:
set
- Existing Set to wrap.
-
-
Method Details
-
equals
-
hashCode
public int hashCode() -
toString
-
size
public int size() -
isEmpty
public boolean isEmpty() -
contains
-
iterator
-
toArray
-
toArray
public <T1> T1[] toArray(T1[] a) -
containsAll
- Specified by:
containsAll
in interfaceCollection<T>
- Specified by:
containsAll
in interfaceSet<T>
-
add
-
remove
-
addAll
-
removeAll
-
retainAll
-
clear
public void clear()
-