public class OpenHashSet<T> extends AbstractSet implements Set<T>
Modifier and Type | Field and Description |
---|---|
protected static byte |
FREE |
protected static byte |
FULL |
protected static char |
NO_KEY_VALUE |
protected static byte |
REMOVED |
DEFAULT_CAPACITY, DEFAULT_MAX_LOAD_FACTOR, DEFAULT_MIN_LOAD_FACTOR, distinct, highWaterMark, lowWaterMark, maxLoadFactor, minLoadFactor
Constructor and Description |
---|
OpenHashSet()
Constructs an empty map with default capacity and default load factors.
|
OpenHashSet(int initialCapacity)
Constructs an empty map with the specified initial capacity and default load factors.
|
OpenHashSet(int initialCapacity,
double minLoadFactor,
double maxLoadFactor)
Constructs an empty map with the specified initial capacity and the specified minimum and maximum load factor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(Object key) |
boolean |
addAll(Collection<? extends T> c) |
void |
clear()
Removes all values associations from the receiver.
|
Object |
clone()
Returns a deep copy of the receiver.
|
boolean |
contains(Object key)
Returns true if the receiver contains the specified key.
|
boolean |
containsAll(Collection<?> c) |
void |
ensureCapacity(int minCapacity)
Ensures that the receiver can hold at least the specified number of associations without needing to allocate new
internal memory.
|
boolean |
equals(Object obj)
OpenHashSet instances are only equal to other OpenHashSet instances, not to
any other collection.
|
boolean |
forEachKey(ObjectProcedure<T> procedure)
Applies a procedure to each key of the receiver, if any.
|
int |
hashCode() |
protected int |
indexOfInsertion(T key) |
protected int |
indexOfKey(T key) |
boolean |
isEmpty()
Returns true if the receiver contains no (key,value) associations.
|
Iterator<T> |
iterator()
Implement the standard Java Collections iterator.
|
List<T> |
keys() |
void |
keys(List<T> list)
Fills all keys contained in the receiver into the specified list.
|
protected void |
rehash(int newCapacity)
Rehashes the contents of the receiver into a new table with a smaller or larger capacity.
|
boolean |
remove(Object key)
Removes the given key with its associated element from the receiver, if present.
|
boolean |
removeAll(Collection<?> c) |
boolean |
retainAll(Collection<?> c) |
protected void |
setUp(int initialCapacity,
double minLoadFactor,
double maxLoadFactor)
Initializes the receiver.
|
Object[] |
toArray() |
<T1> T1[] |
toArray(T1[] a) |
void |
trimToSize()
Trims the capacity of the receiver to be the receiver's current size.
|
chooseGrowCapacity, chooseHighWaterMark, chooseLowWaterMark, chooseMeanCapacity, chooseShrinkCapacity, equalsMindTheNull, nextPrime, size
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
size, spliterator
parallelStream, removeIf, stream
protected static final byte FREE
protected static final byte FULL
protected static final byte REMOVED
protected static final char NO_KEY_VALUE
public OpenHashSet()
public OpenHashSet(int initialCapacity)
initialCapacity
- the initial capacity of the map.IllegalArgumentException
- if the initial capacity is less than zero.public OpenHashSet(int initialCapacity, double minLoadFactor, double maxLoadFactor)
initialCapacity
- the initial capacity.minLoadFactor
- the minimum load factor.maxLoadFactor
- the maximum load factor.IllegalArgumentException
- if initialCapacity < 0 || (minLoadFactor < 0.0 || minLoadFactor >= 1.0) ||
(maxLoadFactor <= 0.0 || maxLoadFactor >= 1.0) || (minLoadFactor >=
maxLoadFactor).public void clear()
clear
in interface Collection<T>
clear
in interface Set<T>
clear
in class AbstractSet
public Object clone()
clone
in class PersistentObject
public boolean contains(Object key)
public void ensureCapacity(int minCapacity)
This method never need be called; it is for performance tuning only. Calling this method before add()ing a large number of associations boosts performance, because the receiver will grow only once instead of potentially many times and hash collisions get less probable.
ensureCapacity
in class AbstractSet
minCapacity
- the desired minimum capacity.public boolean forEachKey(ObjectProcedure<T> procedure)
procedure
- the procedure to be applied. Stops iteration if the procedure returns false, otherwise
continues.protected int indexOfInsertion(T key)
key
- the key to be added to the receiver.protected int indexOfKey(T key)
key
- the key to be searched in the receiver.public void keys(List<T> list)
list
- the list to be filled, can have any size.public boolean add(Object key)
protected void rehash(int newCapacity)
public boolean remove(Object key)
protected final void setUp(int initialCapacity, double minLoadFactor, double maxLoadFactor)
setUp
in class AbstractSet
initialCapacity
- the initial capacity of the receiver.minLoadFactor
- the minLoadFactor of the receiver.maxLoadFactor
- the maxLoadFactor of the receiver.IllegalArgumentException
- if initialCapacity < 0 || (minLoadFactor < 0.0 || minLoadFactor >= 1.0) ||
(maxLoadFactor <= 0.0 || maxLoadFactor >= 1.0) || (minLoadFactor >=
maxLoadFactor).public void trimToSize()
trimToSize
in class AbstractSet
public boolean isEmpty()
AbstractSet
isEmpty
in interface Collection<T>
isEmpty
in interface Set<T>
isEmpty
in class AbstractSet
public boolean equals(Object obj)
public int hashCode()
public Iterator<T> iterator()
public Object[] toArray()
public boolean addAll(Collection<? extends T> c)
public boolean containsAll(Collection<?> c)
containsAll
in interface Collection<T>
containsAll
in interface Set<T>
public boolean removeAll(Collection<?> c)
public boolean retainAll(Collection<?> c)
public <T1> T1[] toArray(T1[] a)
Copyright © 2008–2017 The Apache Software Foundation. All rights reserved.