GNU
|
Liberty Eiffel
|
Automated Tests
|
Wiki
|
Savannah project
|
Debian packages
|
Documentation
>
libraries
>
RANDOM_NUMBER_GENERATOR
+
Point of view
All features
ANY
All features
deferred class RANDOM_NUMBER_GENERATOR
Summary
top
Common abstract definition of a random number generator. The Liberty Eiffel library provides two implementations:
MINIMAL_RANDOM_NUMBER_GENERATOR
, and
PRESS_RANDOM_NUMBER_GENERATOR
. Most applications can safely rely on
MINIMAL_RANDOM_NUMBER_GENERATOR
. If you really need high quality randomizing, consider
PRESS_RANDOM_NUMBER_GENERATOR
.
Direct parents
Insert list:
ANY
Known children
Inherit list:
MINIMAL_RANDOM_NUMBER_GENERATOR
Overview
top
Features
{
ANY
}
make
Create (or reset) the random number generator with an automatic randomised setting of the
seed_value
based on the CPU clock.
with_seed
(seed_value:
INTEGER_32
)
Create (or reset) the random number generator with an explicit
seed_value
.
next
Prepare the next random number in sequence.
last_real
:
REAL_64
The last computed number in range 0.0 to 1.0 excluded (see ensure).
last_integer
(n:
INTEGER_32
):
INTEGER_32
The last computed number in range 1 to
n
(see ensure).
{}
clock_based_random_seed
:
INTEGER_32
Some positive random value to be used as a seed which may change as much as possible in a random way.
make
deferred procedure
{
ANY
}
top
Create (or reset) the random number generator with an automatic randomised setting of the
seed_value
based on the CPU clock.
See also
with_seed
.
with_seed
(seed_value:
INTEGER_32
)
deferred procedure
{
ANY
}
top
Create (or reset) the random number generator with an explicit
seed_value
.
By using an explicit
seed_value
, one can replay the very same random sequense more than once
See also
make
.
next
deferred procedure
{
ANY
}
top
Prepare the next random number in sequence.
Change internal memory of
Current
in order to prepare the next random number in sequence.
See also
last_real
,
last_integer
.
last_real
:
REAL_64
deferred function
{
ANY
}
top
The last computed number in range 0.0 to 1.0 excluded (see ensure).
Internal memory is not changed and two calls will give the same
Result
. Use
next
to get a new random
last_real
value.
See also
last_integer
.
ensure
Result > 0 and Result <= 1
last_integer
(n:
INTEGER_32
):
INTEGER_32
deferred function
{
ANY
}
top
The last computed number in range 1 to
n
(see ensure).
Internal memory is not changed and two calls will give the same
Result
. Use
next
to get a new random
last_integer
value.
See also
last_real
.
require
n >= 1
ensure
1 <= Result and Result <= n
clock_based_random_seed
:
INTEGER_32
effective function
{}
top
Some positive random value to be used as a seed which may change as much as possible in a random way.
ensure
Result > 0