<?xml version="1.0" encoding="utf-8"?>
<refentry xml:id="random-engine-xoshiro256starstar.jump" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
 <refnamediv>
  <refname>Random\Engine\Xoshiro256StarStar::jump</refname>
  <refpurpose>Efficiently move the engine ahead by 2^128 steps</refpurpose>
 </refnamediv>

 <refsect1 role="description">
  &reftitle.description;
  <methodsynopsis role="Random\\Engine\\Xoshiro256StarStar">
   <modifier>public</modifier> <type>void</type><methodname>Random\Engine\Xoshiro256StarStar::jump</methodname>
   <void/>
  </methodsynopsis>
  <para>
   Moves the algorithm’s state ahead by 2<superscript>128</superscript> steps, as if
   <function>Random\Engine\Xoshiro256StarStar::generate</function> was called
   2<superscript>128</superscript> times.
  </para>
  <para>
   The purpose of a jump is to facilitate the creation of a new <classname>Random\Engine\Xoshiro256StarStar</classname>
   engine from an existing seeded <classname>Random\Engine\Xoshiro256StarStar</classname> engine.
   The seeded engine acts as a blueprint, which can be <link linkend="language.oop5.cloning">cloned</link>
   and repeatedly jumped to create 2<superscript>128</superscript> non-overlapping sequences with
   2<superscript>128</superscript> values each.
  </para>
 </refsect1>

 <refsect1 role="parameters">
  &reftitle.parameters;
  &no.function.parameters;
 </refsect1>

 <refsect1 role="returnvalues">
  &reftitle.returnvalues;
  <para>
   &return.void;
  </para>
 </refsect1>

 <refsect1 role="examples">
  &reftitle.examples;
  <example>
   <title><function>Random\Engine\Xoshiro256StarStar::jump</function> example</title>
   <programlisting role="php">
<![CDATA[
<?php
use Random\Engine\Xoshiro256StarStar;
use Random\Randomizer;

$blueprintRng = new Xoshiro256StarStar(0);

$fibers = [];
for ($i = 0; $i < 8; $i++) {
    $fiberRng = clone $blueprintRng;
    $blueprintRng->jump();

    $fiber = new Fiber(static function () use ($fiberRng, $i): void {
        $randomizer = new Randomizer($fiberRng);

        while (true) {
            Fiber::suspend();

            echo "{$i}: ", $randomizer->getInt(0, 100), "\n";
        }
    });
    $fiber->start();

    $fibers[] = $fiber;
}

// Even though the fibers execute in a random order, they will print the same value
// each time, because each has its own unique instance of the RNG.
$randomizer = new Randomizer();

$fibers = $randomizer->shuffleArray($fibers);
foreach ($fibers as $fiber) {
    $fiber->resume();
}

$fibers = $randomizer->shuffleArray($fibers);
foreach ($fibers as $fiber) {
    $fiber->resume();
}
?>
]]>
   </programlisting>
   &example.outputs.similar;
   <screen>
<![CDATA[
4: 89
3: 10
2: 63
1: 75
6: 41
5: 56
0: 16
7: 60
7: 34
6: 58
1: 74
4: 63
3: 3
5: 42
2: 45
0: 86
]]>
   </screen>
  </example>
 </refsect1>

 <refsect1 role="seealso">
  &reftitle.seealso;
  <simplelist>
   <member><function>Random\Engine\Xoshiro256StarStar::jumpLong</function></member>
  </simplelist>
 </refsect1>

</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
