]> git.proxmox.com Git - rustc.git/blob - src/libcollectionstest/btree/mod.rs
Imported Upstream version 1.11.0+dfsg1
[rustc.git] / src / libcollectionstest / btree / mod.rs
1 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 mod map;
12 mod set;
13
14 /// XorShiftRng
15 struct DeterministicRng {
16 x: u32,
17 y: u32,
18 z: u32,
19 w: u32,
20 }
21
22 impl DeterministicRng {
23 fn new() -> Self {
24 DeterministicRng {
25 x: 0x193a6754,
26 y: 0xa8a7d469,
27 z: 0x97830e05,
28 w: 0x113ba7bb
29 }
30 }
31
32 fn next(&mut self) -> u32 {
33 let x = self.x;
34 let t = x ^ (x << 11);
35 self.x = self.y;
36 self.y = self.z;
37 self.z = self.w;
38 let w_ = self.w;
39 self.w = w_ ^ (w_ >> 19) ^ (t ^ (t >> 8));
40 self.w
41 }
42 }