DayByDayTests/SeededGenerator.swift
14 lines · 424 bytes
1 symbol in this file
1/// Deterministic SplitMix64 generator for tests.
2nonisolated struct SeededGenerator: RandomNumberGenerator {
3 private var state: UInt64
4
5 init(seed: UInt64) { state = seed }
6
7 mutating func next() -> UInt64 {
8 state &+= 0x9E37_79B9_7F4A_7C15
9 var z = state
10 z = (z ^ (z >> 30)) &* 0xBF58_476D_1CE4_E5B9
11 z = (z ^ (z >> 27)) &* 0x94D0_49BB_1331_11EB
12 return z ^ (z >> 31)
13 }
14}