Package org.apache.cxf.common.util
Class SortedArraySet<T>
java.lang.Object
org.apache.cxf.common.util.SortedArraySet<T>
- Type Parameters:
T
-
- All Implemented Interfaces:
Iterable<T>
,Collection<T>
,Set<T>
,SortedSet<T>
This class implements most of the Set interface, backed by a
sorted Array. This makes iterators very fast, lookups are log(n), but
adds are fairly expensive.
This class is also threadsafe, but without synchronizations. Lookups
and iterators will iterate over the state of the Set when the iterator
was created.
If no data is stored in the Set, it uses very little memory. The backing
array is created on demand.
This class is primarily useful for stuff that will be setup at startup, but
then iterated over MANY times during runtime.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
addAll
(Collection<? extends T> c) void
clear()
Comparator<? super T>
boolean
boolean
containsAll
(Collection<?> c) boolean
first()
int
hashCode()
boolean
isEmpty()
iterator()
last()
boolean
boolean
removeAll
(Collection<?> c) boolean
retainAll
(Collection<?> c) int
size()
Object[]
toArray()
<X> X[]
toArray
(X[] 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, toArray
Methods inherited from interface java.util.SortedSet
spliterator
-
Constructor Details
-
SortedArraySet
public SortedArraySet()
-
-
Method Details
-
clear
public void clear() -
isEmpty
public boolean isEmpty() -
iterator
-
size
public int size() -
add
-
addAll
-
containsAll
- Specified by:
containsAll
in interfaceCollection<T>
- Specified by:
containsAll
in interfaceSet<T>
-
contains
-
removeAll
-
retainAll
-
remove
-
toArray
-
toArray
public <X> X[] toArray(X[] a) -
equals
-
toString
-
hashCode
public int hashCode() -
comparator
- Specified by:
comparator
in interfaceSortedSet<T>
-
first
-
last
-
headSet
-
subSet
-
tailSet
-