Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## sim.engine
Class RandomSequence

    java.lang.Object
      sim.engine.Sequence
          sim.engine.RandomSequence

All Implemented Interfaces:
  java.io.Serializable, Steppable

    public class RandomSequence

extends Sequence

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:
  Serialized Form

Field Summary

Fields inherited from class sim.engine.Sequence
`size, steps`

Constructor Summary
`RandomSequence(java.util.Collection steps)` Creates an immutable RandomSequence.
`RandomSequence(java.util.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
`protected boolean` | `canEnsureOrder()` If your subclass does not respect order, override this method to return false, and Sequence will ignore the ensuresOrder result.
`void` | `step(SimState state)`

Methods inherited from class sim.engine.Sequence
`addSteppable, addSteppables, addSteppables, getEnsuresOrder, getUsesSets, loadSteps, removeSteppable, removeSteppables, removeSteppables, replaceSteppables, replaceSteppables, setEnsuresOrder, setUsesSets`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### RandomSequence

    public RandomSequence(Steppable[] steps)

  Creates an immutable RandomSequence. Does not synchronize before using the random number generator

### RandomSequence

    public RandomSequence(Steppable[] steps,
                          boolean shouldSynchronize)

  Creates an immutable RandomSequence. Synchronizes on the random number generator only if shouldSynchronize is true

### RandomSequence

    public RandomSequence(java.util.Collection steps)

  Creates an immutable RandomSequence. Does not synchronize before using the random number generator

### RandomSequence

    public RandomSequence(java.util.Collection steps,
                          boolean shouldSynchronize)

  Creates an immutable RandomSequence. Synchronizes on the random number generator only if shouldSynchronize is true

Method Detail

### 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 class `Sequence`

### step

    public void step(SimState state)

  Specified by:
    `step` in interface `Steppable`
  Overrides:
    `step` in class `Sequence`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD