Add 'discard' method for lfprng
authorunc0rr
Tue, 04 Jun 2019 21:24:07 +0200
changeset 15136 de32299de704
parent 15135 a7841105493e
child 15138 7c4d6246a531
Add 'discard' method for lfprng
rust/lfprng/src/lib.rs
--- a/rust/lfprng/src/lib.rs	Tue Jun 04 20:01:37 2019 +0300
+++ b/rust/lfprng/src/lib.rs	Tue Jun 04 21:24:07 2019 +0200
@@ -16,14 +16,19 @@
             index: 54,
         };
 
-        for _i in 0..2048 {
-            prng.get_next();
-        }
+        prng.discard(2048);
 
         prng
     }
 
     #[inline]
+    pub fn discard(&mut self, count: usize) {
+        for _i in 0..count {
+            self.get_next();
+        }
+    }
+
+    #[inline]
     fn get_next(&mut self) -> u32 {
         self.index = (self.index + 1) & 0x3f;
         self.circular_buffer[self.index] = (self.circular_buffer[(self.index + 40) & 0x3f]