Package gnu.trove.set.hash
Class TCustomHashSet<E>
java.lang.Object
gnu.trove.impl.hash.THash
gnu.trove.impl.hash.TObjectHash<E>
gnu.trove.impl.hash.TCustomObjectHash<E>
gnu.trove.set.hash.TCustomHashSet<E>
- All Implemented Interfaces:
Externalizable
,Serializable
,Iterable<E>
,Collection<E>
,Set<E>
public class TCustomHashSet<E>
extends TCustomObjectHash<E>
implements Set<E>, Iterable<E>, Externalizable
An implementation of the Set interface that uses an
open-addressed hash table to store its contents.
- See Also:
-
Field Summary
Fields inherited from class gnu.trove.impl.hash.TCustomObjectHash
strategy
Fields inherited from class gnu.trove.impl.hash.TObjectHash
_set, consumeFreeSlot, FREE, REMOVED
Fields inherited from class gnu.trove.impl.hash.THash
_autoCompactionFactor, _autoCompactRemovesRemaining, _autoCompactTemporaryDisable, _free, _loadFactor, _maxSize, _size, DEFAULT_CAPACITY, DEFAULT_LOAD_FACTOR
-
Constructor Summary
ConstructorsConstructorDescriptionFOR EXTERNALIZATION ONLY!!!TCustomHashSet
(HashingStrategy<? super E> strategy) Creates a newTHashSet
instance with the default capacity and load factor.TCustomHashSet
(HashingStrategy<? super E> strategy, int initialCapacity) Creates a newTHashSet
instance with a prime capacity equal to or greater than initialCapacity and with the default load factor.TCustomHashSet
(HashingStrategy<? super E> strategy, int initialCapacity, float loadFactor) Creates a newTHashSet
instance with a prime capacity equal to or greater than initialCapacity and with the specified load factor.TCustomHashSet
(HashingStrategy<? super E> strategy, Collection<? extends E> collection) Creates a newTHashSet
instance containing the elements of collection. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Inserts a value into the set.boolean
addAll
(Collection<? extends E> collection) Adds all of the elements in collection to the set.void
clear()
Empties the set.boolean
containsAll
(Collection<?> collection) Tests the set to determine if all of the elements in collection are present.boolean
int
hashCode()
iterator()
Creates an iterator over the values of the set.void
protected void
rehash
(int newCapacity) Expands the set to accommodate new values.boolean
Removes obj from the set.boolean
removeAll
(Collection<?> collection) Removes all of the elements in collection from the set.boolean
retainAll
(Collection<?> collection) Removes any values in the set which are not contained in collection.Object[]
toArray()
Returns a new array containing the objects in the set.<T> T[]
toArray
(T[] a) Returns a typed array of the objects in the set.toString()
void
Methods inherited from class gnu.trove.impl.hash.TCustomObjectHash
equals, hash
Methods inherited from class gnu.trove.impl.hash.TObjectHash
buildObjectContractViolation, capacity, contains, dumpExtraInfo, forEach, index, insertionIndex, insertKey, objectInfo, removeAt, reportPotentialConcurrentMod, setUp, throwObjectContractViolation, throwObjectContractViolation
Methods inherited from class gnu.trove.impl.hash.THash
calculateGrownCapacity, compact, computeMaxSize, computeNextAutoCompactionAmount, ensureCapacity, fastCeil, getAutoCompactionFactor, isEmpty, postInsertHook, reenableAutoCompaction, saturatedCast, setAutoCompactionFactor, size, tempDisableAutoCompaction, trimToSize
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
contains, isEmpty, size, spliterator
-
Constructor Details
-
TCustomHashSet
public TCustomHashSet()FOR EXTERNALIZATION ONLY!!! -
TCustomHashSet
Creates a newTHashSet
instance with the default capacity and load factor. -
TCustomHashSet
Creates a newTHashSet
instance with a prime capacity equal to or greater than initialCapacity and with the default load factor.- Parameters:
initialCapacity
- anint
value
-
TCustomHashSet
Creates a newTHashSet
instance with a prime capacity equal to or greater than initialCapacity and with the specified load factor.- Parameters:
initialCapacity
- anint
valueloadFactor
- afloat
value
-
TCustomHashSet
Creates a newTHashSet
instance containing the elements of collection.- Parameters:
collection
- aCollection
value
-
-
Method Details
-
add
Inserts a value into the set. -
equals
-
hashCode
public int hashCode() -
rehash
protected void rehash(int newCapacity) Expands the set to accommodate new values. -
toArray
Returns a new array containing the objects in the set. -
toArray
public <T> T[] toArray(T[] a) Returns a typed array of the objects in the set. -
clear
public void clear()Empties the set. -
remove
Removes obj from the set. -
iterator
Creates an iterator over the values of the set. The iterator supports element deletion. -
containsAll
Tests the set to determine if all of the elements in collection are present.- Specified by:
containsAll
in interfaceCollection<E>
- Specified by:
containsAll
in interfaceSet<E>
- Parameters:
collection
- aCollection
value- Returns:
- true if all elements were present in the set.
-
addAll
Adds all of the elements in collection to the set. -
removeAll
Removes all of the elements in collection from the set. -
retainAll
Removes any values in the set which are not contained in collection. -
toString
-
writeExternal
- Specified by:
writeExternal
in interfaceExternalizable
- Overrides:
writeExternal
in classTCustomObjectHash<E>
- Throws:
IOException
-
readExternal
- Specified by:
readExternal
in interfaceExternalizable
- Overrides:
readExternal
in classTCustomObjectHash<E>
- Throws:
IOException
ClassNotFoundException
-