infoservice.dynamic
Class ComleteRandomStrategy

java.lang.Object
  extended by infoservice.dynamic.ADynamicCascadeBuildingStrategy
      extended by infoservice.dynamic.ComleteRandomStrategy
All Implemented Interfaces:
IDynamicCascadeBuildingStrategy

public class ComleteRandomStrategy
extends ADynamicCascadeBuildingStrategy

This is an implementation of a IDynamicCascadeBuildingStrategy. It creates new cascades purly at random using the seed previously agreed upon by all other InfoServices.

Author:
ss1

Constructor Summary
ComleteRandomStrategy()
           
 
Method Summary
 java.util.Vector circuit(java.util.Vector firstAndMiddleMixes, java.util.Vector lastMixes, long seedForRandomGenerator)
          Creates the mix cascades.
 java.util.Vector createCascades(java.util.Vector firstMixes, java.util.Vector middleMixes, java.util.Vector lastMixes, long seed)
          Creates new mix cascades out of the given first, middle and last mixes.
private  java.util.Vector randomizeIt(java.util.Vector a_vector, int[] a_randArr)
          Randomizes the given Vector
private  java.util.Vector randomizeVector(java.util.Vector a_vector, java.util.Random a_random)
          Randomizes the given Vector using the given Random.
 
Methods inherited from class infoservice.dynamic.ADynamicCascadeBuildingStrategy
buildCascade
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ComleteRandomStrategy

public ComleteRandomStrategy()
Method Detail

createCascades

public java.util.Vector createCascades(java.util.Vector firstMixes,
                                       java.util.Vector middleMixes,
                                       java.util.Vector lastMixes,
                                       long seed)
                                throws java.lang.Exception
Description copied from interface: IDynamicCascadeBuildingStrategy
Creates new mix cascades out of the given first, middle and last mixes. The result is a Vector of MixCascades. The given seed must be used as the seed for a PRNG, as all InfoServices must come to the same resulting cascades.

Specified by:
createCascades in interface IDynamicCascadeBuildingStrategy
Specified by:
createCascades in class ADynamicCascadeBuildingStrategy
Parameters:
firstMixes - The MixInfos of the first mixes to be used
middleMixes - The MixInfos of the middle mixes to be used
lastMixes - The MixInfos of the last mixes to be used
seed - The seed for the PRNG
Returns:
A Vector if MixCascade containing the new cascades
Throws:
java.lang.Exception

circuit

public java.util.Vector circuit(java.util.Vector firstAndMiddleMixes,
                                java.util.Vector lastMixes,
                                long seedForRandomGenerator)
                         throws java.lang.Exception
Creates the mix cascades.

Parameters:
firstAndMiddleMixes - Set of available first and middle mixes.
lastMixes - Set of available last-mixes.
seedForRandomGenerator -
Returns:
Vector with three ones in it. Each one contains a quantity of cascades with equal length.
Throws:
java.lang.Exception

randomizeIt

private java.util.Vector randomizeIt(java.util.Vector a_vector,
                                     int[] a_randArr)
Randomizes the given Vector

Parameters:
a_vector -
a_randArr -
Returns:

randomizeVector

private java.util.Vector randomizeVector(java.util.Vector a_vector,
                                         java.util.Random a_random)
Randomizes the given Vector using the given Random.

Parameters:
a_vector - The Vector to be randomized
a_random - The Random to use
Returns:
The randomized Vector