module JavaRandom: sig .. end
Pseudorandom number generators.
Instance creation
val make_of_seed : java_long -> t
val make_secure : ?algorithm:JavaString.t -> ?provider:JavaString.t -> unit -> t
Returns a new
java.security.SecureRandom instance, using
algorithm
(if different from
null
) to generate the numbers as
implemented by
provider
(if different from
null
).
Both
algorithm
and
provider
default to
null
.
Raises Java_exception
if the specified algorithm or provider cannot be
found
val current_thread_local : unit -> t
Numbers generation
val next_boolean : t -> java_boolean
val next_bytes : t -> java_byte java_byte_array -> unit
val next_double : t -> java_double
val next_float : t -> java_float
val next_gaussian : t -> java_double
Generates a new pseudorandom double that is Gaussian distributed; see
nextGaussian(...).
val next_int : t -> java_int
val next_int_bound : t -> java_int -> java_int
Generates a new pseudorandom integer between 0 (inclusive) and the
passed value (exclusive); see
nextInt(...).
val next_long : t -> java_long
Generator seed
val set_seed : t -> java_long -> unit
set_seed random seed
Sets the seed of the
random
generator to
seed
; see
setSeed(...).
Null value
val null : t
The null
value.
val is_null : t -> bool
is_null obj
returns true
iff obj
is equal to null
.
val is_not_null : t -> bool
is_not_null obj
returns false
iff obj
is equal to null
.
Miscellaneous
val wrap : t -> t option
wrap obj
wraps the reference
obj
into an option type:
Some x
if obj
is not null
;
None
if obj
is null
.
val unwrap : t option -> t
unwrap obj
unwraps the option
obj
into a bare reference:
Some x
is mapped to x
;
None
is mapped to null
.