sdsu.algorithms.data
Class OrderedNumberGenerator
java.lang.Object
|
+--sdsu.algorithms.data.OrderedNumberGenerator
- public class OrderedNumberGenerator
- extends java.lang.Object
- implements NumberGenerator
This class generates a sequence of numbers. The sequence has a starting number
and an increment. The sequence is generated by adding the increment to the last
number. If increment is positive get an increasing sequence, if negative get a
decreasing sequence. Returns inf (or -inf) in unlikey case when reach the end
of the double value ( about 1.79769e+308 on the upper range).
- Version:
- 1.0 18 June 1997
- Author:
- Roger Whitney (whitney@cs.sdsu.edu)
- See Also:
sdsu.data.NumberGenerator
Constructor Summary |
OrderedNumberGenerator()
Creates a sequence of numbers starting at 0 and
increment 1. |
OrderedNumberGenerator(double startNumber)
Creates a sequence of numbers starting at startNumber
and increment 1. |
OrderedNumberGenerator(double startNumber,
double increment)
Creates an sequence of numbers starting at startNumber
and increment increment. |
Method Summary |
double |
nextElement()
Returns the next number in the ordered sequence. |
Methods inherited from class java.lang.Object |
equals,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
OrderedNumberGenerator
public OrderedNumberGenerator()
- Creates a sequence of numbers starting at 0 and
increment 1.
OrderedNumberGenerator
public OrderedNumberGenerator(double startNumber)
- Creates a sequence of numbers starting at startNumber
and increment 1.
OrderedNumberGenerator
public OrderedNumberGenerator(double startNumber,
double increment)
throws java.lang.IllegalArgumentException
- Creates an sequence of numbers starting at startNumber
and increment increment.
- Throws:
- java.lang.IllegalArgumentException - if increment == 0 (zero)
nextElement
public final double nextElement()
- Returns the next number in the ordered sequence.
If reach the end of the range of double, will return inf.
As the max value of a float is about 1.79769e+308 any reasonable
starting value and increment will not reach that value.
- Specified by:
- nextElement in interface NumberGenerator