Class IntrusiveArraySet<T>
java.lang.Object
com.illumon.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>
public class IntrusiveArraySet<T> extends Object implements 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
Nested Classes Modifier and Type Class Description static interfaceIntrusiveArraySet.Adapter<T>Adapter interface for elements to be entered into the set. -
Constructor Summary
Constructors Constructor Description IntrusiveArraySet(IntrusiveArraySet.Adapter<T> adapter, Class<T> elementClass)IntrusiveArraySet(IntrusiveArraySet.Adapter<T> adapter, Class<T> elementClass, int initialCapacity) -
Method Summary
Modifier and Type Method Description booleanadd(T t)booleanaddAll(Collection<? extends T> c)voidclear()booleancontains(Object o)booleancontainsAll(Collection<?> collection)voidensureCapacity(int capacity)booleanisEmpty()Iterator<T>iterator()booleanremove(Object o)booleanremoveAll(Collection<?> collection)booleanretainAll(Collection<?> collection)intsize()Object[]toArray()<T1> T1[]toArray(T1[] a)
-
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> T1[] toArray(@NotNull T1[] a) -
add
-
remove
-
containsAll
- Specified by:
containsAllin interfaceCollection<T>- Specified by:
containsAllin interfaceSet<T>
-
addAll
-
retainAll
-
removeAll
-
clear
public void clear()
-