mirror of
https://github.com/apple/swift-argument-parser.git
synced 2026-05-07 20:12:41 +00:00
27 lines
831 B
Swift
27 lines
831 B
Swift
//===----------------------------------------------------------*- swift -*-===//
|
|
//
|
|
// This source file is part of the Swift Argument Parser open source project
|
|
//
|
|
// Copyright (c) 2020 Apple Inc. and the Swift project authors
|
|
// Licensed under Apache License v2.0 with Runtime Library Exception
|
|
//
|
|
// See https://swift.org/LICENSE.txt for license information
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
struct SplitMix64: RandomNumberGenerator {
|
|
private var state: UInt64
|
|
|
|
init(seed: UInt64) {
|
|
self.state = seed
|
|
}
|
|
|
|
mutating func next() -> UInt64 {
|
|
self.state &+= 0x9e3779b97f4a7c15
|
|
var z: UInt64 = self.state
|
|
z = (z ^ (z &>> 30)) &* 0xbf58476d1ce4e5b9
|
|
z = (z ^ (z &>> 27)) &* 0x94d049bb133111eb
|
|
return z ^ (z &>> 31)
|
|
}
|
|
}
|