Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
BTreeMap/BTreeSet: separate off code supporting tests
- Loading branch information
Showing
6 changed files
with
34 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pub mod ord_chaos; | ||
pub mod rng; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/// XorShiftRng | ||
pub struct DeterministicRng { | ||
count: usize, | ||
x: u32, | ||
y: u32, | ||
z: u32, | ||
w: u32, | ||
} | ||
|
||
impl DeterministicRng { | ||
pub fn new() -> Self { | ||
DeterministicRng { count: 0, x: 0x193a6754, y: 0xa8a7d469, z: 0x97830e05, w: 0x113ba7bb } | ||
} | ||
|
||
/// Guarantees that each returned number is unique. | ||
pub fn next(&mut self) -> u32 { | ||
self.count += 1; | ||
assert!(self.count <= 70029); | ||
let x = self.x; | ||
let t = x ^ (x << 11); | ||
self.x = self.y; | ||
self.y = self.z; | ||
self.z = self.w; | ||
let w_ = self.w; | ||
self.w = w_ ^ (w_ >> 19) ^ (t ^ (t >> 8)); | ||
self.w | ||
} | ||
} |