Package gnu.trove.set.hash
Class THashSet<E>
- java.lang.Object
-
- gnu.trove.impl.hash.THash
-
- gnu.trove.impl.hash.TObjectHash<E>
-
- gnu.trove.set.hash.THashSet<E>
-
- All Implemented Interfaces:
java.io.Externalizable,java.io.Serializable,java.lang.Iterable<E>,java.util.Collection<E>,java.util.Set<E>
public class THashSet<E> extends TObjectHash<E> implements java.util.Set<E>, java.lang.Iterable<E>, java.io.Externalizable
An implementation of the Set interface that uses an open-addressed hash table to store its contents.- See Also:
- Serialized Form
-
-
Field Summary
-
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
Constructors Constructor Description THashSet()Creates a newTHashSetinstance with the default capacity and load factor.THashSet(int initialCapacity)Creates a newTHashSetinstance with a prime capacity equal to or greater than initialCapacity and with the default load factor.THashSet(int initialCapacity, float loadFactor)Creates a newTHashSetinstance with a prime capacity equal to or greater than initialCapacity and with the specified load factor.THashSet(java.util.Collection<? extends E> collection)Creates a newTHashSetinstance containing the elements of collection.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(E obj)Inserts a value into the set.booleanaddAll(java.util.Collection<? extends E> collection)Adds all of the elements in collection to the set.voidclear()Empties the set.booleancontainsAll(java.util.Collection<?> collection)Tests the set to determine if all of the elements in collection are present.booleanequals(java.lang.Object other)inthashCode()TObjectHashIterator<E>iterator()Creates an iterator over the values of the set.voidreadExternal(java.io.ObjectInput in)protected voidrehash(int newCapacity)Expands the set to accommodate new values.booleanremove(java.lang.Object obj)Removes obj from the set.booleanremoveAll(java.util.Collection<?> collection)Removes all of the elements in collection from the set.booleanretainAll(java.util.Collection<?> collection)Removes any values in the set which are not contained in collection.java.lang.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.java.lang.StringtoString()protected voidwriteEntries(java.io.ObjectOutput out)voidwriteExternal(java.io.ObjectOutput out)-
Methods inherited from class gnu.trove.impl.hash.TObjectHash
buildObjectContractViolation, capacity, contains, dumpExtraInfo, equals, forEach, hash, 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
-
-
-
-
Constructor Detail
-
THashSet
public THashSet()
Creates a newTHashSetinstance with the default capacity and load factor.
-
THashSet
public THashSet(int initialCapacity)
Creates a newTHashSetinstance with a prime capacity equal to or greater than initialCapacity and with the default load factor.- Parameters:
initialCapacity- anintvalue
-
THashSet
public THashSet(int initialCapacity, float loadFactor)Creates a newTHashSetinstance with a prime capacity equal to or greater than initialCapacity and with the specified load factor.- Parameters:
initialCapacity- anintvalueloadFactor- afloatvalue
-
THashSet
public THashSet(java.util.Collection<? extends E> collection)
Creates a newTHashSetinstance containing the elements of collection.- Parameters:
collection- aCollectionvalue
-
-
Method Detail
-
add
public boolean add(E obj)
Inserts a value into the set.
-
equals
public boolean equals(java.lang.Object other)
-
hashCode
public int hashCode()
-
rehash
protected void rehash(int newCapacity)
Expands the set to accommodate new values.
-
toArray
public java.lang.Object[] 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
public boolean remove(java.lang.Object obj)
Removes obj from the set.
-
iterator
public TObjectHashIterator<E> iterator()
Creates an iterator over the values of the set. The iterator supports element deletion.
-
containsAll
public boolean containsAll(java.util.Collection<?> collection)
Tests the set to determine if all of the elements in collection are present.
-
addAll
public boolean addAll(java.util.Collection<? extends E> collection)
Adds all of the elements in collection to the set.
-
removeAll
public boolean removeAll(java.util.Collection<?> collection)
Removes all of the elements in collection from the set.
-
retainAll
public boolean retainAll(java.util.Collection<?> collection)
Removes any values in the set which are not contained in collection.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
writeExternal
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException- Specified by:
writeExternalin interfacejava.io.Externalizable- Overrides:
writeExternalin classTObjectHash<E>- Throws:
java.io.IOException
-
writeEntries
protected void writeEntries(java.io.ObjectOutput out) throws java.io.IOException- Throws:
java.io.IOException
-
readExternal
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException- Specified by:
readExternalin interfacejava.io.Externalizable- Overrides:
readExternalin classTObjectHash<E>- Throws:
java.io.IOExceptionjava.lang.ClassNotFoundException
-
-