JSci.maths
Class FiniteSet

java.lang.Object
  extended by JSci.maths.FiniteSet
All Implemented Interfaces:
MathSet

public final class FiniteSet
extends java.lang.Object
implements MathSet

A set containing a finite number of elements. This class provides a bridge between java.util.Set and JSci.maths.MathSet.


Constructor Summary
FiniteSet(java.util.Set set)
          Constructs a finite set.
 
Method Summary
 int cardinality()
          Returns the cardinality.
 boolean equals(java.lang.Object s)
          Compares two sets for equality.
 java.util.Set getElements()
          Returns the elements of this set.
 int hashCode()
           
 MathSet intersect(MathSet set)
          Performs the intersection of this set with another.
 java.lang.String toString()
          Returns a string representing this set.
 MathSet union(MathSet set)
          Performs the union of this set with another.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FiniteSet

public FiniteSet(java.util.Set set)
Constructs a finite set.

Parameters:
set - a set of elements
Method Detail

equals

public boolean equals(java.lang.Object s)
Compares two sets for equality.

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Returns a string representing this set.

Overrides:
toString in class java.lang.Object

getElements

public java.util.Set getElements()
Returns the elements of this set.


cardinality

public int cardinality()
Returns the cardinality.

Specified by:
cardinality in interface MathSet

union

public MathSet union(MathSet set)
Performs the union of this set with another.

Specified by:
union in interface MathSet
Parameters:
set - a set.
Returns:
the union of the two sets.

intersect

public MathSet intersect(MathSet set)
Performs the intersection of this set with another.

Specified by:
intersect in interface MathSet
Parameters:
set - a set.
Returns:
the intersection of the two sets.