Class IntrusiveArraySet<T>
java.lang.Object
io.deephaven.util.datastructures.intrusive.IntrusiveArraySet<T>
- Type Parameters:
T
- the type of the element we are storing.
- All Implemented Interfaces:
Iterable<T>
,Collection<T>
,Set<T>
An intrusive set that uses an array for its backing storage.
You can insert, remove, or check for existence in O(1) time. Clearing the set is O(n); as we need to null out references.
If you attempt to perform an operation element which is not in this set, but is in another set with the same adapter; then you are going to have a bad time. Tread carefully.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Adapter interface for elements to be entered into the set. -
Constructor Summary
ConstructorDescriptionIntrusiveArraySet
(IntrusiveArraySet.Adapter<T> adapter, Class<T> elementClass) IntrusiveArraySet
(IntrusiveArraySet.Adapter<T> adapter, Class<T> elementClass, int initialCapacity) -
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
addAll
(@NotNull Collection<? extends T> c) void
clear()
boolean
boolean
containsAll
(@NotNull Collection<?> collection) void
ensureCapacity
(int capacity) boolean
isEmpty()
iterator()
boolean
boolean
removeAll
(@NotNull Collection<?> collection) boolean
retainAll
(@NotNull Collection<?> collection) int
size()
void
sort
(@NotNull Comparator<? super T> c) Sort the contents of this IntrusiveArraySet according toc
.@NotNull Object[]
toArray()
<T1> @NotNull T1[]
toArray
(@NotNull T1[] a) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
Methods inherited from interface java.util.Set
equals, hashCode, spliterator
-
Constructor Details
-
IntrusiveArraySet
-
IntrusiveArraySet
public IntrusiveArraySet(IntrusiveArraySet.Adapter<T> adapter, Class<T> elementClass, int initialCapacity)
-
-
Method Details
-
ensureCapacity
public void ensureCapacity(int capacity) -
size
public int size() -
isEmpty
public boolean isEmpty() -
contains
-
iterator
-
toArray
-
toArray
@NotNull public <T1> @NotNull T1[] toArray(@NotNull @NotNull T1[] a) -
add
-
remove
-
containsAll
- Specified by:
containsAll
in interfaceCollection<T>
- Specified by:
containsAll
in interfaceSet<T>
-
addAll
-
retainAll
-
removeAll
-
clear
public void clear() -
sort
Sort the contents of this IntrusiveArraySet according toc
. Any subsequent mutation may render this IntrusiveArraySet unsorted, as removes are done in O(1) time by swapping with the last element.- Parameters:
c
- TheComparator
to sort by
-