Package com.tangosol.util
Class OpenHashSet<E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractSet<E>
com.tangosol.util.OpenHashSet<E>
- Type Parameters:
E
- the type of elements that can be managed by this set
- All Implemented Interfaces:
Iterable<E>
,Collection<E>
,Set<E>
An implementation of
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.
- Since:
- 12.2.1
- Author:
- cp 2013.01.15
-
Constructor Summary
ConstructorDescriptionDefault constructor.OpenHashSet
(int initialCapacity) Create a OpenHashSet pre-sized to hold the specified number of elements.OpenHashSet
(Collection<? extends E> coll) Create a OpenHashSet that will initially contain the contents of the passed Collection. -
Method Summary
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, isEmpty, retainAll, 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.Set
addAll, containsAll, isEmpty, retainAll, spliterator
-
Constructor Details
-
OpenHashSet
public OpenHashSet()Default constructor. -
OpenHashSet
public OpenHashSet(int initialCapacity) Create a OpenHashSet pre-sized to hold the specified number of elements.- Parameters:
initialCapacity
- the initial capacity requirement for the hash set
-
OpenHashSet
Create a OpenHashSet that will initially contain the contents of the passed Collection. In other words, this is a "copy constructor".- Parameters:
coll
- the Collection whose contents this
-
-
Method Details
-
size
public int size()- Specified by:
size
in interfaceCollection<E>
- Specified by:
size
in interfaceSet<E>
- Specified by:
size
in classAbstractCollection<E>
-
contains
- Specified by:
contains
in interfaceCollection<E>
- Specified by:
contains
in interfaceSet<E>
- Overrides:
contains
in classAbstractCollection<E>
-
add
- Specified by:
add
in interfaceCollection<E>
- Specified by:
add
in interfaceSet<E>
- Overrides:
add
in classAbstractCollection<E>
-
remove
- Specified by:
remove
in interfaceCollection<E>
- Specified by:
remove
in interfaceSet<E>
- Overrides:
remove
in classAbstractCollection<E>
-
clear
public void clear()- Specified by:
clear
in interfaceCollection<E>
- Specified by:
clear
in interfaceSet<E>
- Overrides:
clear
in classAbstractCollection<E>
-
iterator
-
toArray
- Specified by:
toArray
in interfaceCollection<E>
- Specified by:
toArray
in interfaceSet<E>
- Overrides:
toArray
in classAbstractCollection<E>
-
toArray
public <T> T[] toArray(T[] a) - Specified by:
toArray
in interfaceCollection<E>
- Specified by:
toArray
in interfaceSet<E>
- Overrides:
toArray
in classAbstractCollection<E>
-
getElement
Expose the indexed element storage to sub-classes in a range-unsafe manner.- Parameters:
n
- an element index- Returns:
- the value stored at the specified index; note that a null value is not differentiable from an empty element, since both are returned as null
-