All Packages Class Hierarchy This Package Previous Next Index
Class sdsu.algorithms.data.OrderedNumberGenerator
java.lang.Object
|
+----sdsu.algorithms.data.OrderedNumberGenerator
- public class OrderedNumberGenerator
- extends 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:
- NumberGenerator
-
OrderedNumberGenerator()
- Creates a sequence of numbers starting at 0 and
increment 1.
-
OrderedNumberGenerator(double)
- Creates a sequence of numbers starting at startNumber
and increment 1.
-
OrderedNumberGenerator(double, double)
- Creates an sequence of numbers starting at startNumber
and increment increment.
-
nextElement()
- Returns the next number in the ordered sequence.
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 IllegalArgumentException
- Creates an sequence of numbers starting at startNumber
and increment increment.
- Throws: 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.
All Packages Class Hierarchy This Package Previous Next Index