org.jscience.mathematics
Class FiniteSet

java.lang.Object
  extended by org.jscience.mathematics.FiniteSet
All Implemented Interfaces:
Set

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

A set containing a finite number of elements. This class provides a bridge between java.util.Set and org.jscience.mathematics.Set.


Field Summary
static FiniteSet EMPTY
          DOCUMENT ME!
 
Constructor Summary
FiniteSet(FiniteSet set)
          Constructs a finite set.
FiniteSet(java.lang.Object elem)
          Constructs a finite set.
 
Method Summary
 int cardinality()
          Returns the cardinality.
 boolean contains(java.lang.Object o)
          Returns true if this set contains the specified element.
 boolean equals(java.lang.Object s)
          Compares the specified object with this set for equality.
 java.util.Set getElements()
          Returns the elements of this set.
 int hashCode()
          Returns the hash code value for this set.
 Set intersection(Set set)
          Performs the intersection of this set with another.
 boolean isEmpty()
          Returns true if this set contains no elements.
 java.util.Iterator iterator()
          Returns an iterator over the elements in this set.
 boolean remove(java.lang.Object o)
          Removes the specified element from this set if it is present (optional operation).
 java.lang.Object[] toArray()
          Returns an array containing all of the elements in this set.
 java.lang.String toString()
          Returns a string representing this set.
 Set union(Set set)
          Performs the union of this set with another.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY

public static final FiniteSet EMPTY
DOCUMENT ME!

Constructor Detail

FiniteSet

public FiniteSet(FiniteSet set)
Constructs a finite set.

Parameters:
set - a set of elements

FiniteSet

public FiniteSet(java.lang.Object elem)
Constructs a finite set.

Parameters:
elem - a element for the set
Method Detail

cardinality

public int cardinality()
Returns the cardinality.

Specified by:
cardinality in interface Set
Returns:
DOCUMENT ME!

isEmpty

public boolean isEmpty()
Returns true if this set contains no elements.

Specified by:
isEmpty in interface Set
Returns:
true if this set contains no elements.

union

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

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

intersection

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

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

contains

public boolean contains(java.lang.Object o)
Returns true if this set contains the specified element.

Specified by:
contains in interface Set
Parameters:
o - - element whose presence in this set is to be tested.
Returns:
true if this set contains the specified element.

remove

public boolean remove(java.lang.Object o)
Removes the specified element from this set if it is present (optional operation).

Specified by:
remove in interface Set
Parameters:
o - - object to be removed from this set, if present.
Returns:
true if the set contained the specified element.

equals

public boolean equals(java.lang.Object s)
Compares the specified object with this set for equality.

Specified by:
equals in interface Set
Overrides:
equals in class java.lang.Object
Parameters:
s - - Object to be compared for equality with this set.
Returns:
true if the specified Object is equal to this set.

hashCode

public int hashCode()
Returns the hash code value for this set.

Specified by:
hashCode in interface Set
Overrides:
hashCode in class java.lang.Object
Returns:
the hash code value for this set.

toString

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

Overrides:
toString in class java.lang.Object
Returns:
DOCUMENT ME!

iterator

public java.util.Iterator iterator()
Returns an iterator over the elements in this set.

Specified by:
iterator in interface Set
Returns:
an iterator over the elements in this set.

getElements

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

Returns:
DOCUMENT ME!

toArray

public java.lang.Object[] toArray()
Returns an array containing all of the elements in this set.

Specified by:
toArray in interface Set
Returns:
an array containing all of the elements in this set.