java.lang.Object
org.glassfish.grizzly.utils.ArraySet<T>
- All Implemented Interfaces:
Iterable<T>,Collection<T>,Set<T>
The thread safe set implementation, which uses array to hold its elements. This set could be used, for cases, which
require minimum set modifications.
- Author:
- Alexey Stashok
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanAdd all the elements from the source ArraySet.booleanbooleanaddAll(Collection<? extends T> collection) final booleanAdd the element(s) to the set.voidclear()Remove all the set elements.booleanbooleancontainsAll(Collection<?> collection) final T[]getArray()Get the underlying array.final T[]Get the copy of the underlying array.booleanisEmpty()iterator()final T[]Get the copy of the underlying array.booleanfinal booleanRemove element(s) from the set.booleanremoveAll(Collection<?> collection) booleanretainAll(Collection<?> collection) intsize()Object[]toArray()<K> K[]toArray(K[] a) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.Set
equals, hashCode, spliterator
-
Constructor Details
-
ArraySet
-
ArraySet
-
-
Method Details
-
addAll
Add the element(s) to the set.- Parameters:
elements- the elements to add.- Returns:
- true, if at least one element was added to the set and, as result, the size of the set was increased, or false, all element(s) was/were present in the set and, as the result, the set values were just reset.
-
addAll
-
add
Add all the elements from the source ArraySet.- Parameters:
source- the elements to add.- Returns:
- true, if at least one element was added to the set and, as result, the size of the set was increased, or false, all element(s) was/were present in the set and, as the result, the set values were just reset.
-
removeAll
Remove element(s) from the set.- Parameters:
elements- the element(s) to remove.- Returns:
- true, if at least one element was found and removed, or false otherwise.
-
getArray
Get the underlying array. Please note, it's not appropriate to modify the returned array's content. Please useadd(Object)andremove(Object)instead.- Returns:
- the array.
-
getArrayCopy
Get the copy of the underlying array. If the underlying array is null - then null will be returned.- Returns:
- the copy of the underlying array. If the underlying array is null - then null will be returned.
-
obtainArrayCopy
Get the copy of the underlying array. If the underlying array is null - then empty array will be returned.- Returns:
- the copy of the underlying array. If the underlying array is null - then empty array will be returned.
-
clear
public void clear()Remove all the set elements. -
size
public int size() -
isEmpty
public boolean isEmpty() -
add
-
contains
-
toArray
-
toArray
public <K> K[] toArray(K[] a) -
remove
-
containsAll
- Specified by:
containsAllin interfaceCollection<T>- Specified by:
containsAllin interfaceSet<T>
-
retainAll
-
removeAll
-
iterator
-