Class ListNumberGenerator
java.lang.Object
ListNumberGenerator
- All Implemented Interfaces:
NumberGenerator
public class ListNumberGenerator extends Object implements NumberGenerator
Produces deterministic numbers by iterating repeatedly over a
list or array of integers argued in the constructors.
-
Field Summary
Fields Modifier and Type Field Description (package private) int
index
(package private) List<Integer>
list
(package private) int
smallestUpperBound
-
Constructor Summary
Constructors Constructor Description ListNumberGenerator(Integer[] arr)
Creates a ListNumberGenerator which generates numbers based off of an array of possible integers.ListNumberGenerator(List<Integer> list)
Creates a ListNumberGenerator which generates numbers based off of a list of possible integers. -
Method Summary
-
Field Details
-
list
-
index
int index -
smallestUpperBound
int smallestUpperBound
-
-
Constructor Details
-
ListNumberGenerator
Creates a ListNumberGenerator which generates numbers based off of a list of possible integers.- Parameters:
list
- - an list of integers to step through and output in the generator.
-
ListNumberGenerator
Creates a ListNumberGenerator which generates numbers based off of an array of possible integers.- Parameters:
arr
- - an array of integers to step through and output in the generator.
-
-
Method Details
-
next
public int next()Returns the next integer available in the list.- Returns:
- an unbounded number from the list.
-
next
public int next(int bound)Returns the next integer available in the list that is less than the specified bound.- Specified by:
next
in interfaceNumberGenerator
- Parameters:
bound
- - the max value that can be returned by this call to next.- Returns:
- a number between 0 and bound (inclusive)
-