Package sim.engine
Class RandomSequence
java.lang.Object
sim.engine.Sequence
sim.engine.RandomSequence
- All Implemented Interfaces:
Serializable
,Steppable
RandomSequence is a Sequence which executes its Steppable objects in random order each time.
The RandomSequence uses the random number generator to do its shuffling. If you use a RandomSequence within a ParallelSequence, or inside an AsynchronousSteppable, or in some other multithreaded condition, you should let the RandomSequence know this so that it will lock on the random number generator properly. This is done by setting the shouldSynchronize flag in the RandomSequence. Likewise, whenever in other threads you access the generator in a multithreaded context, you should have them synchronize on the generator first.
Be sure to read the class documentation on sim.engine.Sequence
- See Also:
-
Field Summary
-
Constructor Summary
ConstructorDescriptionRandomSequence
(Collection steps) Creates an immutable RandomSequence.RandomSequence
(Collection steps, boolean shouldSynchronize) Creates an immutable RandomSequence.RandomSequence
(Steppable[] steps) Creates an immutable RandomSequence.RandomSequence
(Steppable[] steps, boolean shouldSynchronize) Creates an immutable RandomSequence. -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
If your subclass does not respect order, override this method to return false, and Sequence will ignore the ensuresOrder result.void
Methods inherited from class sim.engine.Sequence
addSteppable, addSteppables, addSteppables, getEnsuresOrder, getUsesSets, loadSteps, removeSteppable, removeSteppables, removeSteppables, replaceSteppables, replaceSteppables, setEnsuresOrder, setUsesSets
-
Constructor Details
-
RandomSequence
Creates an immutable RandomSequence. Does not synchronize before using the random number generator -
RandomSequence
Creates an immutable RandomSequence. Synchronizes on the random number generator only if shouldSynchronize is true -
RandomSequence
Creates an immutable RandomSequence. Does not synchronize before using the random number generator -
RandomSequence
Creates an immutable RandomSequence. Synchronizes on the random number generator only if shouldSynchronize is true
-
-
Method Details
-
canEnsureOrder
protected boolean canEnsureOrder()Description copied from class:Sequence
If your subclass does not respect order, override this method to return false, and Sequence will ignore the ensuresOrder result.- Overrides:
canEnsureOrder
in classSequence
-
step
-