|
Evaluating Software Design Patterns — the "Gang of Four" patterns implemented in Java 6 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object dk.rode.thesis.meta.model.AbstractSequence<Integer> dk.rode.thesis.facade.RandomSequence dk.rode.thesis.facade.UnboundedRandomSequence
@Participant(value="SubsystemClass") class UnboundedRandomSequence
An unbounded random sequence returns a pseudo integer random number
with each call to next()
with no upper bound.
It uses an internal sequence to deliver an an integer value that will be multiplied with a random value to generate a sequence value.
An unbounded random sequence is unbounded
,
inconsistent
, and not
unique
.
RandomSequence
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface dk.rode.thesis.meta.model.Sequence |
---|
Sequence.State |
Field Summary | |
---|---|
private Sequence<? extends Number> |
sequence
A sequence to deliver unbounded long values. |
Fields inherited from class dk.rode.thesis.meta.model.AbstractSequence |
---|
state |
Constructor Summary | |
---|---|
UnboundedRandomSequence()
No-arg constructor. |
|
UnboundedRandomSequence(Sequence<? extends Number> sequence)
Constructor. |
|
UnboundedRandomSequence(UnboundedRandomSequence sequence)
Copy constructor. |
Method Summary | |
---|---|
boolean |
bounded()
Returns false. |
UnboundedRandomSequence |
copy()
Returns a copy of this sequence that will start at the same sequence index as this sequence. |
Integer |
current()
Returns the current element from this sequence. |
Integer |
next()
Returns the next element from this sequence. |
void |
reset()
Resets this sequence to start over if it is consistent. |
private static int |
value(int random,
Number number)
Calculates the current value of this sequence. |
Methods inherited from class dk.rode.thesis.facade.RandomSequence |
---|
consistent, unique |
Methods inherited from class dk.rode.thesis.meta.model.AbstractSequence |
---|
getStringablePolicy, state, toString, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface dk.rode.thesis.meta.model.Sequence |
---|
consistent, state, unique |
Methods inherited from interface dk.rode.thesis.strategy.Stringable |
---|
getStringablePolicy, toString |
Field Detail |
---|
private final Sequence<? extends Number> sequence
Never null.
Constructor Detail |
---|
public UnboundedRandomSequence()
A LongSequence
is used to deliver the unbounded
long values used internally.
public UnboundedRandomSequence(Sequence<? extends Number> sequence)
sequence
- The sequence to deliver a long value
that will be multiplied with a random value;
cannot be null.
NullPointerException
- If sequence
is null.public UnboundedRandomSequence(UnboundedRandomSequence sequence)
sequence
- The sequence to copy; cannot be null.
NullPointerException
- If sequence
is null.Method Detail |
---|
public boolean bounded()
bounded
in interface Sequence<Integer>
bounded
in class RandomSequence
Sequence.unique()
public UnboundedRandomSequence copy()
Sequence
copy
in interface Sequence<Integer>
copy
in interface Copyable<Sequence<Integer>>
copy
in class RandomSequence
public Integer current()
Sequence
This method can be invoked even if Sequence.next()
has not been invoked yet, thus delivering the initial
value of this sequence.
current
in interface Sequence<Integer>
current
in class RandomSequence
public Integer next()
Sequence
next
in interface Sequence<Integer>
next
in class RandomSequence
Sequence.current()
,
Sequence.state()
public void reset()
Sequence
If this sequence is consistent
, the
sequence will restart.
reset
in interface Sequence<Integer>
reset
in class RandomSequence
private static final int value(int random, Number number)
random
- The random number.number
- The unbounded number.
|
Gunni Rode / rode.dk | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |