|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--uk.org.ogsadai.activity.files.InfiniteSet
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,...].
Field Summary | |
private static java.lang.String |
COPYRIGHT_NOTICE
Copyright statement |
private java.util.Set |
mNumbers
|
private java.util.Set |
mSequences
|
Constructor Summary | |
InfiniteSet()
Default constructor. |
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 |
Field Detail |
private static final java.lang.String COPYRIGHT_NOTICE
private java.util.Set mNumbers
private java.util.Set mSequences
Constructor Detail |
public InfiniteSet()
Method Detail |
public java.lang.String toString()
toString
in class java.lang.Object
public void add(Sequence seq)
seq
- The sequence to addpublic void add(int from, int to)
{x |from
< x < & x <to
}
from
- The start of the intervalto
- The end of the intervalpublic void add(int val)
val
- Value to add.public boolean isMember(int val) throws NonIncreasingSequenceException
val
- The integer to test for membership
true
if the integer is a member of this setfalse
otherwise
NonIncreasingSequenceException
- If each element of the sequence is not strictly greater
than its predecessor.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |