E - the type of elements that can be managed by this setpublic class OpenHashSet<E> extends AbstractSet<E>
Set that is optimized for memory footprint. Specifically, instead of delegating to a HashMap which instantiates an "Entry" object for each element (as the HashSet does, which references those entries in a linked list fashion with the head of the linked list stored in the hash bucket array, this implementation stores its elements using an open hashing algorithm, i.e. the elements are stored directly in the hash bucket array.
This implementation is explicitly NOT thread-safe.
| Constructor and Description |
|---|
OpenHashSet()
Default constructor.
|
OpenHashSet(Collection<? extends E> coll)
Create a OpenHashSet that will initially contain the contents of the passed Collection.
|
OpenHashSet(int initialCapacity)
Create a OpenHashSet pre-sized to hold the specified number of elements.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(E e) |
void |
clear() |
boolean |
contains(Object o) |
protected E |
getElement(int n)
Expose the indexed element storage to sub-classes in a range-unsafe manner.
|
Iterator<E> |
iterator() |
boolean |
remove(Object o) |
int |
size() |
Object[] |
toArray() |
<T> T[] |
toArray(T[] a) |
equals, hashCode, removeAlladdAll, containsAll, isEmpty, retainAll, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitaddAll, containsAll, isEmpty, retainAll, spliteratorparallelStream, removeIf, streampublic OpenHashSet()
public OpenHashSet(int initialCapacity)
initialCapacity - the initial capacity requirement for the hash setpublic OpenHashSet(Collection<? extends E> coll)
coll - the Collection whose contents thispublic int size()
size in interface Collection<E>size in interface Set<E>size in class AbstractCollection<E>public boolean contains(Object o)
contains in interface Collection<E>contains in interface Set<E>contains in class AbstractCollection<E>public boolean add(E e)
add in interface Collection<E>add in interface Set<E>add in class AbstractCollection<E>public boolean remove(Object o)
remove in interface Collection<E>remove in interface Set<E>remove in class AbstractCollection<E>public void clear()
clear in interface Collection<E>clear in interface Set<E>clear in class AbstractCollection<E>public Object[] toArray()
toArray in interface Collection<E>toArray in interface Set<E>toArray in class AbstractCollection<E>public <T> T[] toArray(T[] a)
toArray in interface Collection<E>toArray in interface Set<E>toArray in class AbstractCollection<E>protected E getElement(int n)
n - an element index