org.jscience.mathematics
Interface Set

All Known Implementing Classes:
FiniteSet, FinSet.FunctionSet, Interval, IntervalsList

public interface Set

This interface defines a mathematical set. The name duplicates the java.util.Set and shares much the same intent although this class is meant to have the genuine meaning. You may use this interface to define finite or infinite sets.


Method Summary
 int cardinality()
          Returns the number of elements in this set (its cardinality).
 boolean contains(java.lang.Object o)
          Returns true if this set contains the specified element.
 boolean equals(java.lang.Object o)
          Compares the specified object with this set for equality.
 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 (optional operation, as it is meaningless for infinite sets).
 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 (optional operation, as it is meaningless for infinite sets).
 Set union(Set set)
          Performs the union of this set with another.
 

Method Detail

cardinality

int cardinality()
Returns the number of elements in this set (its cardinality).

Returns:
the number of elements in this set (its cardinality).

isEmpty

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

Returns:
true if this set contains no elements.

iterator

java.util.Iterator iterator()
Returns an iterator over the elements in this set (optional operation, as it is meaningless for infinite sets).

Returns:
an iterator over the elements in this set.

union

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

Parameters:
set - a set.
Returns:
the union of the two sets.

intersection

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

Parameters:
set - a set.
Returns:
the intersection of the two sets.

remove

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

Parameters:
o - - object to be removed from this set, if present.
Returns:
true if the set contained the specified element.

contains

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

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

equals

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

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

hashCode

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

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

toArray

java.lang.Object[] toArray()
Returns an array containing all of the elements in this set (optional operation, as it is meaningless for infinite sets).

Returns:
an array containing all of the elements in this set.