gnu.trove

Class THashSet

public class THashSet extends TObjectHash implements Set, Serializable

An implementation of the Set interface that uses an open-addressed hash table to store its contents. Created: Sat Nov 3 10:38:17 2001

Version: $Id: THashSet.java,v 1.11 2003/03/23 04:06:59 ericdf Exp $

Author: Eric D. Friedman

Nested Class Summary
classTHashSet.HashProcedure
Constructor Summary
THashSet()
Creates a new THashSet instance with the default capacity and load factor.
THashSet(TObjectHashingStrategy strategy)
Creates a new THashSet instance with the default capacity and load factor.
THashSet(int initialCapacity)
Creates a new THashSet instance with a prime capacity equal to or greater than initialCapacity and with the default load factor.
THashSet(int initialCapacity, TObjectHashingStrategy strategy)
Creates a new THashSet instance with a prime capacity equal to or greater than initialCapacity and with the default load factor.
THashSet(int initialCapacity, float loadFactor)
Creates a new THashSet instance with a prime capacity equal to or greater than initialCapacity and with the specified load factor.
THashSet(int initialCapacity, float loadFactor, TObjectHashingStrategy strategy)
Creates a new THashSet instance with a prime capacity equal to or greater than initialCapacity and with the specified load factor.
THashSet(Collection collection)
Creates a new THashSet instance containing the elements of collection.
THashSet(Collection collection, TObjectHashingStrategy strategy)
Creates a new THashSet instance containing the elements of collection.
Method Summary
booleanadd(Object obj)
Inserts a value into the set.
booleanaddAll(Collection 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.
booleanequals(Object other)
inthashCode()
Iteratoriterator()
Creates an iterator over the values of the set.
voidreadObject(ObjectInputStream stream)
protected voidrehash(int newCapacity)
Expands the set to accomodate new values.
booleanremove(Object obj)
Removes 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.
Object[]toArray(Object[] a)
Returns a typed array of the objects in the set.
voidwriteObject(ObjectOutputStream stream)

Constructor Detail

THashSet

public THashSet()
Creates a new THashSet instance with the default capacity and load factor.

THashSet

public THashSet(TObjectHashingStrategy strategy)
Creates a new THashSet instance with the default capacity and load factor.

Parameters: strategy used to compute hash codes and to compare objects.

THashSet

public THashSet(int initialCapacity)
Creates a new THashSet instance with a prime capacity equal to or greater than initialCapacity and with the default load factor.

Parameters: initialCapacity an int value

THashSet

public THashSet(int initialCapacity, TObjectHashingStrategy strategy)
Creates a new THashSet instance with a prime capacity equal to or greater than initialCapacity and with the default load factor.

Parameters: initialCapacity an int value strategy used to compute hash codes and to compare objects.

THashSet

public THashSet(int initialCapacity, float loadFactor)
Creates a new THashSet instance with a prime capacity equal to or greater than initialCapacity and with the specified load factor.

Parameters: initialCapacity an int value loadFactor a float value

THashSet

public THashSet(int initialCapacity, float loadFactor, TObjectHashingStrategy strategy)
Creates a new THashSet instance with a prime capacity equal to or greater than initialCapacity and with the specified load factor.

Parameters: initialCapacity an int value loadFactor a float value strategy used to compute hash codes and to compare objects.

THashSet

public THashSet(Collection collection)
Creates a new THashSet instance containing the elements of collection.

Parameters: collection a Collection value

THashSet

public THashSet(Collection collection, TObjectHashingStrategy strategy)
Creates a new THashSet instance containing the elements of collection.

Parameters: collection a Collection value strategy used to compute hash codes and to compare objects.

Method Detail

add

public boolean add(Object obj)
Inserts a value into the set.

Parameters: obj an Object value

Returns: true if the set was modified by the add operation

addAll

public boolean addAll(Collection collection)
Adds all of the elements in collection to the set.

Parameters: collection a Collection value

Returns: true if the set was modified by the add all operation.

clear

public void clear()
Empties the set.

containsAll

public boolean containsAll(Collection collection)
Tests the set to determine if all of the elements in collection are present.

Parameters: collection a Collection value

Returns: true if all elements were present in the set.

equals

public boolean equals(Object other)

hashCode

public int hashCode()

iterator

public Iterator iterator()
Creates an iterator over the values of the set. The iterator supports element deletion.

Returns: an Iterator value

readObject

private void readObject(ObjectInputStream stream)

rehash

protected void rehash(int newCapacity)
Expands the set to accomodate new values.

Parameters: newCapacity an int value

remove

public boolean remove(Object obj)
Removes obj from the set.

Parameters: obj an Object value

Returns: true if the set was modified by the remove operation.

removeAll

public boolean removeAll(Collection collection)
Removes all of the elements in collection from the set.

Parameters: collection a Collection value

Returns: true if the set was modified by the remove all operation.

retainAll

public boolean retainAll(Collection collection)
Removes any values in the set which are not contained in collection.

Parameters: collection a Collection value

Returns: true if the set was modified by the retain all operation

toArray

public Object[] toArray()
Returns a new array containing the objects in the set.

Returns: an Object[] value

toArray

public Object[] toArray(Object[] a)
Returns a typed array of the objects in the set.

Parameters: a an Object[] value

Returns: an Object[] value

writeObject

private void writeObject(ObjectOutputStream stream)