File tree 1 file changed +19
-2
lines changed
1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -430,11 +430,28 @@ impl<R: BlockRngCore> BlockRng64<R> {
430
430
& mut self . core
431
431
}
432
432
433
- // Reset the number of available results.
434
- // This will force a new set of results to be generated on next use.
433
+ /// Get the index into the result buffer.
434
+ ///
435
+ /// If this is equal to or larger than the size of the result buffer then
436
+ /// the buffer is "empty" and `generate()` must be called to produce new
437
+ /// results.
438
+ pub fn index ( & self ) -> usize {
439
+ self . index
440
+ }
441
+
442
+ /// Reset the number of available results.
443
+ /// This will force a new set of results to be generated on next use.
435
444
pub fn reset ( & mut self ) {
436
445
self . index = self . results . as_ref ( ) . len ( ) ;
437
446
}
447
+
448
+ /// Generate a new set of results immediately, setting the index to the
449
+ /// given value.
450
+ pub fn generate_and_set ( & mut self , index : usize ) {
451
+ assert ! ( index < self . results. as_ref( ) . len( ) ) ;
452
+ self . core . generate ( & mut self . results ) ;
453
+ self . index = index;
454
+ }
438
455
}
439
456
440
457
impl < R : BlockRngCore < Item =u64 > > RngCore for BlockRng64 < R >
You can’t perform that action at this time.
0 commit comments