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
strategyFields inherited from class gnu.trove.impl.hash.TObjectHash
_set, consumeFreeSlot, FREE, REMOVEDFields 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 newTHashSetinstance with the default capacity and load factor.TCustomHashSet(HashingStrategy<? super E> strategy, int initialCapacity) Creates a newTHashSetinstance 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 newTHashSetinstance 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 newTHashSetinstance containing the elements of collection. -
Method Summary
Modifier and TypeMethodDescriptionbooleanInserts a value into the set.booleanaddAll(Collection<? extends E> collection) Adds all of the elements in collection to the set.voidclear()Empties the set.booleancontainsAll(Collection<?> collection) Tests the set to determine if all of the elements in collection are present.booleaninthashCode()iterator()Creates an iterator over the values of the set.voidprotected voidrehash(int newCapacity) Expands the set to accommodate new values.booleanRemoves obj from the set.booleanremoveAll(Collection<?> collection) Removes all of the elements in collection from the set.booleanretainAll(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()voidMethods inherited from class gnu.trove.impl.hash.TCustomObjectHash
equals, hashMethods inherited from class gnu.trove.impl.hash.TObjectHash
buildObjectContractViolation, capacity, contains, dumpExtraInfo, forEach, index, insertionIndex, insertKey, objectInfo, removeAt, reportPotentialConcurrentMod, setUp, throwObjectContractViolation, throwObjectContractViolationMethods inherited from class gnu.trove.impl.hash.THash
calculateGrownCapacity, compact, computeMaxSize, computeNextAutoCompactionAmount, ensureCapacity, fastCeil, getAutoCompactionFactor, isEmpty, postInsertHook, reenableAutoCompaction, saturatedCast, setAutoCompactionFactor, size, tempDisableAutoCompaction, trimToSizeMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface java.util.Set
contains, isEmpty, size, spliterator
-
Constructor Details
-
TCustomHashSet
public TCustomHashSet()FOR EXTERNALIZATION ONLY!!! -
TCustomHashSet
Creates a newTHashSetinstance with the default capacity and load factor. -
TCustomHashSet
Creates a newTHashSetinstance with a prime capacity equal to or greater than initialCapacity and with the default load factor.- Parameters:
initialCapacity- anintvalue
-
TCustomHashSet
Creates a newTHashSetinstance with a prime capacity equal to or greater than initialCapacity and with the specified load factor.- Parameters:
initialCapacity- anintvalueloadFactor- afloatvalue
-
TCustomHashSet
Creates a newTHashSetinstance containing the elements of collection.- Parameters:
collection- aCollectionvalue
-
-
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:
containsAllin interfaceCollection<E>- Specified by:
containsAllin interfaceSet<E>- Parameters:
collection- aCollectionvalue- 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:
writeExternalin interfaceExternalizable- Overrides:
writeExternalin classTCustomObjectHash<E>- Throws:
IOException
-
readExternal
- Specified by:
readExternalin interfaceExternalizable- Overrides:
readExternalin classTCustomObjectHash<E>- Throws:
IOExceptionClassNotFoundException
-