org.zedlib
Class HashSet

java.lang.Object
  extended byjava.util.AbstractCollection
      extended byjava.util.AbstractSet
          extended byjava.util.HashSet
              extended byorg.zedlib.HashSet
All Implemented Interfaces:
Cloneable, Collection, Serializable, Set, Set
Direct Known Subclasses:
HashRel

public class HashSet
extends HashSet
implements Set

A collection that contains no duplicate elements. As implied by its name, this class models the mathematical set abstraction.

Author:
Brad Long
See Also:
Serialized Form

Constructor Summary
HashSet()
           
HashSet(Collection c)
          Constructs a set containing all elements in the supplied collection
HashSet(Object o)
          Constructs a set containing only this object
 
Method Summary
 Relation cartesianProduct(Set y)
          Constructs the cartesian product (X x Y) of two sets X and Y.
 Set difference(Collection c)
          Constructs the difference of this set with the collection of given sets.
 Set difference(Set t)
          Returns the difference of a given set with this set.
protected  Set getInstance()
           
protected  Set getInstance(Set s)
           
 Relation identity()
          Constructs a relation mapping each value in this set onto itself.
 Set intersection(Collection c)
          Constructs the intersection of this set and the collection of given sets.
 Set intersection(Set t)
          Returns the intersection of this set with a given set.
 boolean isProperSubsetOf(Set t)
          Determines whether this set is a proper subset of a given set.
 boolean isSubsetOf(Set t)
          Determines whether a given set contains at least the elements in this set.
 boolean isSupersetOf(Set t)
          Determines whether this set contains at least the elements in a given set.
 Set union(Collection c)
          Constructs the union of this set with the collection of given sets.
 Set union(Set t)
          Constructs the union of a given set with this set.
 
Methods inherited from class java.util.HashSet
add, clear, clone, contains, isEmpty, iterator, remove, size
 
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
 
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 

Constructor Detail

HashSet

public HashSet()

HashSet

public HashSet(Collection c)
Constructs a set containing all elements in the supplied collection


HashSet

public HashSet(Object o)
Constructs a set containing only this object

Method Detail

getInstance

protected Set getInstance()

getInstance

protected Set getInstance(Set s)

union

public Set union(Set t)
Constructs the union of a given set with this set. The members of S.union(T) are those objects which are members of S or T or both.

Specified by:
union in interface Set
Parameters:
t - the set to union with this set
Returns:
a set being the union of this and t
See Also:
Set.addAll(Collection c)

union

public Set union(Collection c)
Constructs the union of this set with the collection of given sets.


difference

public Set difference(Set t)
Returns the difference of a given set with this set. The members of S.subtract(T) are those objects which are members of S but not of T.

Specified by:
difference in interface Set
Parameters:
t - the set to subtract from this set
Returns:
a set being the difference between this and t
See Also:
Set.removeAll(Collection c)

difference

public Set difference(Collection c)
Constructs the difference of this set with the collection of given sets.


intersection

public Set intersection(Set t)
Returns the intersection of this set with a given set. The members of S.intersect(T) are those objects which are members of both S and T.

Specified by:
intersection in interface Set
Parameters:
t - the set with which to intersect
Returns:
a set being the intersection of this and t
See Also:
Set.retainAll(Collection c)

intersection

public Set intersection(Collection c)
Constructs the intersection of this set and the collection of given sets.


isSubsetOf

public boolean isSubsetOf(Set t)
Determines whether a given set contains at least the elements in this set.

Specified by:
isSubsetOf in interface Set
Parameters:
t - the given set with which to compare
Returns:
true if this set is a subset of t

isProperSubsetOf

public boolean isProperSubsetOf(Set t)
Determines whether this set is a proper subset of a given set.

Parameters:
t - the given set with which to compare
Returns:
true if this set is a subset of t

isSupersetOf

public boolean isSupersetOf(Set t)
Determines whether this set contains at least the elements in a given set.

Specified by:
isSupersetOf in interface Set
Parameters:
t - the given set with which to compare
Returns:
true if this set is a superset of t

identity

public Relation identity()
Constructs a relation mapping each value in this set onto itself.

Specified by:
identity in interface Set
Returns:
the identity Relation for this set

cartesianProduct

public Relation cartesianProduct(Set y)
Constructs the cartesian product (X x Y) of two sets X and Y.

Specified by:
cartesianProduct in interface Set
Parameters:
y - the set Y in X x Y
Returns:
the cartesian product of this set and the given set.


Copyright © 2006 Brad Long. All Rights Reserved.