master
 1//! Generator to extend 64-bit seed values into longer sequences.
 2//!
 3//! The number of cycles is thus limited to 64-bits regardless of the engine, but this
 4//! is still plenty for practical purposes.
 5
 6const SplitMix64 = @This();
 7
 8s: u64,
 9
10pub fn init(seed: u64) SplitMix64 {
11    return SplitMix64{ .s = seed };
12}
13
14pub fn next(self: *SplitMix64) u64 {
15    self.s +%= 0x9e3779b97f4a7c15;
16
17    var z = self.s;
18    z = (z ^ (z >> 30)) *% 0xbf58476d1ce4e5b9;
19    z = (z ^ (z >> 27)) *% 0x94d049bb133111eb;
20    return z ^ (z >> 31);
21}