org.zedlib
Interface Set

All Superinterfaces:
Collection, Set
All Known Subinterfaces:
Bag, Function, Relation, Sequence
All Known Implementing Classes:
HashBag, HashFun, HashRel, HashSeq, HashSet

public interface Set
extends Set

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

Author:
Brad Long

Method Summary
 Relation cartesianProduct(Set y)
          Constructs the cartesian product (X x Y) of two sets X and Y.
 Set difference(Set t)
          Returns the difference of a given set with this set.
 Relation identity()
          Constructs a relation mapping each value in this set onto itself.
 Set intersection(Set t)
          Returns the intersection of this set with 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(Set t)
          Constructs the union of a given set with this set.
 
Methods inherited from interface java.util.Set
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 

Method Detail

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.

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)

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.

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)

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.

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

isSubsetOf

public boolean isSubsetOf(Set t)
Determines whether a given set contains at least the elements in this 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.

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.

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.

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.