Package jsl.utilities.random.rng
Class RNGStreamManager
- java.lang.Object
-
- jsl.utilities.random.rng.RNGStreamManager
-
- All Implemented Interfaces:
RandomStreamManagerIfc
,RNStreamControlIfc
public class RNGStreamManager extends java.lang.Object implements RandomStreamManagerIfc
A wrapper for holding a list of streams so that all streams can be managed together The methods of the RandomStreamIfc are applied to all contained random number streams
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<RNStreamIfc>
myStreams
Holds the streams
-
Constructor Summary
Constructors Constructor Description RNGStreamManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(int index, RNStreamIfc element)
Adds the stream to the managerboolean
add(RNStreamIfc e)
Adds the stream to the managerRNStreamIfc
addNewRNStream()
Adds a stream from RNStreamFactory.getDefaultFactory()RNStreamIfc
addNewRNStream(RNStreamFactory f)
Creates a new stream from the supplied factory and adds it to the list of managed streamsvoid
advanceToNextSubstream()
Positions the RNG at the beginning of its next substreamvoid
advanceToNextSubstream(int n)
Causes all managed streams to advance their to the next nth substreamvoid
clear()
boolean
contains(RNStreamIfc o)
Checks if the manager contains the supplied streamRNStreamIfc
get(int index)
Gets the stream at the supplied indexboolean
getAntitheticOption()
int
indexOf(RNStreamIfc o)
Returns the index of the streamboolean
isEmpty()
Checks if the manager is empty (has no streams)java.util.Iterator<RNStreamIfc>
iterator()
static RNGStreamManager
makeRngStreams(int numStreams)
Makes a stream manager and fills it with streams from RNStreamFactory.getDefaultFactory()static RNGStreamManager
makeRngStreams(int numStreams, RNStreamFactory f)
Makes RNStreams and fills a RNGStreamManagerRNStreamIfc
remove(int index)
boolean
remove(RNStreamIfc o)
void
resetStartStream()
The resetStartStream method will position the RNG at the beginning of its stream.void
resetStartSubstream()
Resets the position of the RNG at the start of the current substreamRNStreamIfc
set(int index, RNStreamIfc element)
Sets the stream at the indexvoid
setAntitheticOption(boolean flag)
Tells the stream to start producing antithetic variatesint
size()
Returns the number of streams being managed
-
-
-
Field Detail
-
myStreams
protected java.util.List<RNStreamIfc> myStreams
Holds the streams
-
-
Method Detail
-
makeRngStreams
public static RNGStreamManager makeRngStreams(int numStreams)
Makes a stream manager and fills it with streams from RNStreamFactory.getDefaultFactory()- Parameters:
numStreams
- , must be > 0- Returns:
-
makeRngStreams
public static RNGStreamManager makeRngStreams(int numStreams, RNStreamFactory f)
Makes RNStreams and fills a RNGStreamManager- Parameters:
numStreams
- , must be > 0f
- the factory- Returns:
- the manager
-
resetStartStream
public void resetStartStream()
Description copied from interface:RNStreamControlIfc
The resetStartStream method will position the RNG at the beginning of its stream. This is the same location in the stream as assigned when the RNG was created and initialized.- Specified by:
resetStartStream
in interfaceRNStreamControlIfc
-
resetStartSubstream
public void resetStartSubstream()
Description copied from interface:RNStreamControlIfc
Resets the position of the RNG at the start of the current substream- Specified by:
resetStartSubstream
in interfaceRNStreamControlIfc
-
advanceToNextSubstream
public void advanceToNextSubstream()
Description copied from interface:RNStreamControlIfc
Positions the RNG at the beginning of its next substream- Specified by:
advanceToNextSubstream
in interfaceRNStreamControlIfc
-
advanceToNextSubstream
public void advanceToNextSubstream(int n)
Causes all managed streams to advance their to the next nth substream- Parameters:
n
-
-
setAntitheticOption
public void setAntitheticOption(boolean flag)
Description copied from interface:RNStreamControlIfc
Tells the stream to start producing antithetic variates- Specified by:
setAntitheticOption
in interfaceRNStreamControlIfc
- Parameters:
flag
- true means that it produces antithetic variates.
-
getAntitheticOption
public boolean getAntitheticOption()
- Specified by:
getAntitheticOption
in interfaceRNStreamControlIfc
- Returns:
- true means on
-
size
public int size()
Description copied from interface:RandomStreamManagerIfc
Returns the number of streams being managed- Specified by:
size
in interfaceRandomStreamManagerIfc
- Returns:
-
set
public RNStreamIfc set(int index, RNStreamIfc element)
Sets the stream at the index- Parameters:
index
- , must be a valid indexelement
- , must not be null- Returns:
- the RandomStreamIfc
-
remove
public RNStreamIfc remove(int index)
- Parameters:
index
- must be a valid index- Returns:
- RandomStreamIfc
-
remove
public boolean remove(RNStreamIfc o)
-
iterator
public java.util.Iterator<RNStreamIfc> iterator()
-
isEmpty
public boolean isEmpty()
Description copied from interface:RandomStreamManagerIfc
Checks if the manager is empty (has no streams)- Specified by:
isEmpty
in interfaceRandomStreamManagerIfc
- Returns:
-
indexOf
public int indexOf(RNStreamIfc o)
Description copied from interface:RandomStreamManagerIfc
Returns the index of the stream- Specified by:
indexOf
in interfaceRandomStreamManagerIfc
- Returns:
-
get
public RNStreamIfc get(int index)
Description copied from interface:RandomStreamManagerIfc
Gets the stream at the supplied index- Specified by:
get
in interfaceRandomStreamManagerIfc
- Parameters:
index
- must be a valid index- Returns:
- RandomStreamIfc
-
contains
public boolean contains(RNStreamIfc o)
Description copied from interface:RandomStreamManagerIfc
Checks if the manager contains the supplied stream- Specified by:
contains
in interfaceRandomStreamManagerIfc
- Returns:
-
clear
public void clear()
-
add
public void add(int index, RNStreamIfc element)
Adds the stream to the manager- Parameters:
index
- , must be a valid indexelement
- , must not be null
-
add
public boolean add(RNStreamIfc e)
Adds the stream to the manager- Parameters:
e
- must not be null- Returns:
- true if added
-
addNewRNStream
public RNStreamIfc addNewRNStream()
Adds a stream from RNStreamFactory.getDefaultFactory()- Returns:
- the added RNStream
-
addNewRNStream
public RNStreamIfc addNewRNStream(RNStreamFactory f)
Creates a new stream from the supplied factory and adds it to the list of managed streams- Parameters:
f
- , must not be null- Returns:
- the created stream
-
-