Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: GRand

[13:7] extends: object

The GRand struct is an opaque data structure. It should only be accessed through the g_rand_* functions.

Members

  • handleObj
  • lib
  • retainedCallbacks
  • signalHandlerNames
  • signalSetterHandlers

Methods

  • GRand (seed = null)

    Creates a new random number generator initialized with a seed taken either from /dev/urandom (if existing) or from the current time (as a fallback). On Windows, the seed is taken from rand_s().

    • @p seed is a value to initialize the random number generator.
  • toNativeHandle (Source)

    Normalizes a constructor argument into a raw pointer carrier. Accepts a raw NativeHandle, a raw NativeBuffer returned from fn.call(...), another generated wrapper exposing handle(), or null. Returns null when the argument carries no pointer.

    • @p Source is the raw handle, raw buffer, wrapper, or null.
    • @r A raw pointer carrier or null when no pointer is present.
  • getLib ()

    Returns the opened native library for this generated wrapper.

    • @r The opened native library.
  • handle ()

    Returns the wrapped NativeHandle.

    • @r The wrapped NativeHandle.
  • isNull ()

    Returns true when the wrapped handle is null.

    • @r A bool.
  • describe ()

    Returns a small string for debugging generated wrappers.

    • @r A string.
  • copy ()

    Copies a #GRand into a new one with the same exact state as before. This way you can take a snapshot of the random number generator for replaying later.

    • @r the new #GRand.
  • FnDouble ()

    Returns the next random #gdouble from @rand_ equally distributed over the range [0..1).

    • @r a random number.
  • double_range (double begin, double end)

    Returns the next random #gdouble from @rand_ equally distributed over the range [@begin..@end).

    • @p begin is lower closed bound of the interval.
    • @p end is upper open bound of the interval.
    • @r a random number.
  • free ()

    Frees the memory allocated for the #GRand.

    • @r None.
  • FnInt ()

    Returns the next random #guint32 from @rand_ equally distributed over the range [0..2^32-1].

    • @r a random number.
  • int_range (int begin, int end)

    Returns the next random #gint32 from @rand_ equally distributed over the range [@begin..@end-1].

    • @p begin is lower closed bound of the interval.
    • @p end is upper open bound of the interval.
    • @r a random number.
  • set_seed (int seed)

    Sets the seed for the random number generator #GRand to @seed.

    • @p seed is a value to reinitialize the random number generator.
    • @r None.
  • set_seed_array (int seed, int seed_length)

    Initializes the random number generator by an array of longs. Array can be of arbitrary size, though only the first 624 values are taken. This function is useful if you have many low entropy seeds, or if you require more then 32 bits of actual entropy for your application.

    • @p seed is array to initialize with.
    • @p seed_length is length of array.
    • @r None.

class: GRandCtors

[200:14] static extends: object

Alternate constructors for GRand. Usage: GRandCtors.<name>(...). The primary constructor lives directly on GRand.

Methods

  • newWithSeedArray (int seed, int seed_length)

    Creates a new random number generator initialized with @seed.

    • @p seed is an array of seeds to initialize the random number generator.
    • @p seed_length is an array of seeds to initialize the random number generator.
    • @r A new GRand.