array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'uk', ), 'this' => array ( 0 => 'random-engine-xoshiro256starstar.jump.php', 1 => 'Random\\Engine\\Xoshiro256StarStar::jump', 2 => 'Efficiently move the engine ahead by 2^128 steps', ), 'up' => array ( 0 => 'class.random-engine-xoshiro256starstar.php', 1 => 'Random\\Engine\\Xoshiro256StarStar', ), 'prev' => array ( 0 => 'random-engine-xoshiro256starstar.generate.php', 1 => 'Random\\Engine\\Xoshiro256StarStar::generate', ), 'next' => array ( 0 => 'random-engine-xoshiro256starstar.jumplong.php', 1 => 'Random\\Engine\\Xoshiro256StarStar::jumpLong', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/random/random/engine/xoshiro256starstar/jump.xml', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?>
(PHP 8 >= 8.2.0)
Random\Engine\Xoshiro256StarStar::jump — Efficiently move the engine ahead by 2^128 steps
Moves the algorithm’s state ahead by 2128 steps, as if Random\Engine\Xoshiro256StarStar::generate() was called 2128 times.
The purpose of a jump is to facilitate the creation of a new Random\Engine\Xoshiro256StarStar engine from an existing seeded Random\Engine\Xoshiro256StarStar engine. The seeded engine acts as a blueprint, which can be cloned and repeatedly jumped to create 2128 non-overlapping sequences with 2128 values each.
У цієї функції немає параметрів.
Не повертає значень.
Приклад #1 Random\Engine\Xoshiro256StarStar::jump() example
<?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();
}
?>
Поданий вище приклад виведе щось схоже на:
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