Packagecom.yworks.yfiles.util
Classpublic class YRandom
InheritanceYRandom Inheritance Random Inheritance YObject Inheritance Object

Generates pseudo-random numbers and the such.



Public Properties
 PropertyDefined By
 Inheritedseed : int
[write-only] Sets an int value as seed.
Random
Public Methods
 MethodDefined By
  
YRandom(init:Boolean = true)
Creates a new instance of this class.
YRandom
 Inherited
equals(o:Object):Boolean
YObject
  
getBoolArray(n:int, trueCount:int):Vector.<Boolean>
Returns an array of n randomly chosen boolean values of which trueCount of them are true.
YRandom
  
getClass():Class
[override]
YRandom
  
getIntArray(bucketCount:int, ballCount:int):Vector.<int>
Returns an int array of length bucketCount for which the values of all fields are non-negative and sum up to ballCount.
YRandom
  
getUniqueArray(n:int, min:int, max:int):Vector.<int>
Returns an array of n unique random integers that lie within the range min (inclusive) and max (exclusive).
YRandom
 Inherited
hashCode():int
YObject
 Inherited
[static] Construct a random generator with the current time of day in milliseconds as the initial state.
Random
 Inherited
[static] Construct a random generator with the given seed as the initial state.
Random
  
[static] Creates a new instance of this class.
YRandom
  
[static] Creates a new instance of this class with a given initial random seed.
YRandom
 Inherited
nextBoolean():Boolean
Answers the next pseudo-random, uniformly distributed boolean value generated by this generator.
Random
 Inherited
nextBytes(buf:Vector.<int>):void
Modifies the byte array by a random sequence of bytes generated by this random number generator.
Random
 Inherited
nextDouble():Number
Generates a normally distributed random double number between 0.0 inclusively and 1.0 exclusively.
Random
  
nextDoubleInRange(minValue:Number, maxValue:Number):Number
Returns a double with a random value between minValue (inclusive) and maxValue (exclusive).
YRandom
 Inherited
nextFloat():Number
Generates a normally distributed random float number between 0.0 inclusively and 1.0 exclusively.
Random
 Inherited
nextGaussian():Number
Returns a pseudo-randomly generated, normally distributed double value with mean 0.0 and a standard deviation value of 1.0.
Random
 Inherited
nextInt():int
Generates a uniformly distributed 32-bit int value from the this random number sequence.
Random
  
nextInt2(n:int):int
[override] Returns a pseudo-random, uniformly distributed int value between 0 (inclusive) and the specified value (exclusive), drawn from this random number generator's sequence.
YRandom
  
nextIntInRange(minValue:int, maxValue:int):int
Returns an int with a random value between minValue (inclusive) and maxValue (exclusive).
YRandom
 Inherited
Generates a uniformly distributed 64-bit int value from the this random number sequence.
Random
  
permutate(a:Vector.<Object>):void
Permutes the positions of the elements within the given array.
YRandom
Protected Methods
 MethodDefined By
 Inherited
Initializes this object.
Random
 Inherited
Initializes this object.
Random
  
Initializes this object.
YRandom
  
Initializes this object.
YRandom
 Inherited
next(bits:int):int
Returns a pseudo-random uniformly distributed int value of the number of bits specified by the argument bits.
Random
Constructor Detail
YRandom()Constructor
public function YRandom(init:Boolean = true)

Creates a new instance of this class.

Parameters
init:Boolean (default = true) — An internally used switch to help handle proper instance initialization in inheritance chains where classes can have multiple constructor-like factory methods. This parameter can safely be ignored/omitted when calling the constructor.
Method Detail
getBoolArray()method
public function getBoolArray(n:int, trueCount:int):Vector.<Boolean>

Returns an array of n randomly chosen boolean values of which trueCount of them are true. If the requested numbers of true values is bigger than the number of requested boolean values, an Exception is raised.

Parameters

n:int
 
trueCount:int

Returns
Vector.<Boolean>
getClass()method 
override public function getClass():Class

Returns
Class
getIntArray()method 
public function getIntArray(bucketCount:int, ballCount:int):Vector.<int>

Returns an int array of length bucketCount for which the values of all fields are non-negative and sum up to ballCount. The values are put in the array randomly.

Parameters

bucketCount:int
 
ballCount:int

Returns
Vector.<int>
getUniqueArray()method 
public function getUniqueArray(n:int, min:int, max:int):Vector.<int>

Returns an array of n unique random integers that lie within the range min (inclusive) and max (exclusive). If max - min < n then null is returned.

Parameters

n:int
 
min:int
 
max:int

Returns
Vector.<int>
initYRandom1()method 
protected final function initYRandom1():void

Initializes this object. See the documentation of the corresponding factory method newYRandom1() for details.

See also

initYRandom2()method 
protected final function initYRandom2(seed:LongImpl):void

Initializes this object. See the documentation of the corresponding factory method newYRandom2() for details.

Parameters

seed:LongImpl

See also

newYRandom1()method 
public static function newYRandom1():YRandom

Creates a new instance of this class.

Returns
YRandom
newYRandom2()method 
public static function newYRandom2(seed:LongImpl):YRandom

Creates a new instance of this class with a given initial random seed.

Parameters

seed:LongImpl

Returns
YRandom
nextDoubleInRange()method 
public function nextDoubleInRange(minValue:Number, maxValue:Number):Number

Returns a double with a random value between minValue (inclusive) and maxValue (exclusive).

Precondition maxValue > minValue

Parameters

minValue:Number
 
maxValue:Number

Returns
Number
nextInt2()method 
override public function nextInt2(n:int):int

Returns a pseudo-random, uniformly distributed value between 0 (inclusive) and the specified value (exclusive), drawn from this random number generator's sequence.

Parameters

n:int

Returns
int
nextIntInRange()method 
public function nextIntInRange(minValue:int, maxValue:int):int

Returns an int with a random value between minValue (inclusive) and maxValue (exclusive).

Precondition maxValue > minValue

Parameters

minValue:int
 
maxValue:int

Returns
int
permutate()method 
public function permutate(a:Vector.<Object>):void

Permutes the positions of the elements within the given array.

Parameters

a:Vector.<Object>