 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
public class
SequenceCollection : IEnumerator
|
|
|
{
|
|
|
IntegerSequence sequence; int index;
|
|
|
public SequenceCollection(IntegerSequence
Sequence)
|
|
|
{sequence=Sequence;
index=sequence.Start-1;}
|
|
|
public bool MoveNext()
|
|
|
{++index; return
(index>sequence.End)?false:true;}
|
|
|
public object Current{
|
|
|
get{
|
|
|
if (index<sequence.Start | index>sequence.End)
|
|
|
throw new InvalidOperationException(
|
|
|
"The selected IntegerSequence object is out of range");
|
|
return index;}
|
|
|
}
|
|
|
public void Reset()
{index=sequence.Start-1;}
|
|
|
}
|
|