uk.org.ogsadai.activity.files
Class InfiniteSet
java.lang.Object
|
+--uk.org.ogsadai.activity.files.InfiniteSet
- public class InfiniteSet
- extends java.lang.Object
A class which describes a subset of the integers with potentially infinite cardinality.
Such an infinite set is broken down into a finite set of integers and a finite set of infinite sequences, which together describe every integer in the infinite set.
For example, the set consisting of the first five natural numbers and the set of even natural numbers is an infinite set which may be described by:
{1,2,3,4,5} U {x | x = 0 (mod 2) & x > 0}
This is represented in this datastructure as the set {1,2,3,4,5} and an instance of the Sequence
class, containing the sequence [2,4,...].
- Author:
- The OGSA-DAI Project Team
Method Summary |
void |
add(int val)
Add a single integer to the set. |
void |
add(int from, int to)
Add a finite set of integers into the set. |
void |
add(Sequence seq)
Add an infinite sequence of integers into the set. |
boolean |
isMember(int val)
Test to see if a particular integer is a member of this set. |
java.lang.String |
toString()
Returns a string representation of the contents of this class |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
COPYRIGHT_NOTICE
private static final java.lang.String COPYRIGHT_NOTICE
-
Copyright statement
- See Also:
- Constant Field Values
mNumbers
private java.util.Set mNumbers
-
mSequences
private java.util.Set mSequences
-
InfiniteSet
public InfiniteSet()
-
Default constructor.
toString
public java.lang.String toString()
-
Returns a string representation of the contents of this class
-
- Overrides:
toString
in class java.lang.Object
-
- Returns:
- string
add
public void add(Sequence seq)
-
Add an infinite sequence of integers into the set.
-
- Parameters:
seq
- The sequence to add
add
public void add(int from,
int to)
-
Add a finite set of integers into the set. The set which is unified with the present contents of this class is defined as:
{x | from
< x < & x < to
}
-
- Parameters:
from
- The start of the interval
to
- The end of the interval
add
public void add(int val)
-
Add a single integer to the set.
-
- Parameters:
val
- Value to add.
isMember
public boolean isMember(int val)
throws NonIncreasingSequenceException
-
Test to see if a particular integer is a member of this set.
-
- Parameters:
val
- The integer to test for membership
- Returns:
true
if the integer is a member of this set
false
otherwise
- Throws:
NonIncreasingSequenceException
- If each element of the sequence is not strictly greater than its predecessor.