Block Generator 64<TEngine> Structure
A generator struct that adapts a 64-bit non-counter block engine into the IRandomGenerator interface,
with uint caching for efficient 32-bit word generation.
Definition
Namespace: Numerics.NET.Random.Generators
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.3.0
C#
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.3.0
public struct BlockGenerator64<TEngine> : IRandomGenerator,
IStateful
where TEngine : struct, new(), IBlockEngine<ulong>, IStateful
- Implements
- IRandomGenerator, IStateful
Type Parameters
- TEngine
- The engine type, which must be a struct implementing IBlockEngine<T> for UInt64 and IStateful.
Remarks
BlockGenerator64<TEngine> wraps a non-counter 64-bit block engine and provides:
- NextUInt64(): Returns the next word from the current block via engine.Output(index).
- NextUInt32(): Uses caching to split 64-bit words into two 32-bit words.
- NextBytes(Span<Byte>): Writes bytes via NextUInt32() in 4-byte chunks (little-endian), with tail handling.
Refill Policy (Advance-on-Empty):
When the block is exhausted (_index == BlockLength), the generator calls engine.AdvanceBlock() to move to the next block and resets _index = 0.
Uint Caching:
When NextUInt32() is called, if no cached value exists, the generator calls NextUInt64(), returns the low 32 bits, and caches the high 32 bits for the next call.
State Persistence:
Layer 2 state includes engine state, cursor index (4 bytes LE), cached uint (4 bytes LE), and cache flag (1 byte).
Constructors
| Block | Initializes a new instance of the BlockGenerator64<TEngine> struct with the specified engine. |
Properties
| State | Gets the number of bytes required to save/load this engine's state. |
Methods
| Equals | Indicates whether this instance and a specified object are equal. (Inherited from ValueType) |
| Fill( | Fills the specified span with random double-precision floating-point numbers. |
| Fill( | Fills the specified span with random single-precision floating-point numbers. |
| Fill( | Fills the specified span with random 32-bit unsigned integers. |
| Fill( | Fills the specified span with random 64-bit unsigned integers. |
| Get | Returns the hash code for this instance. (Inherited from ValueType) |
| Get | Gets the Type of the current instance. (Inherited from Object) |
| Load | Loads the engine's state from the source span in a stable little-endian format. |
| Next | Fills the specified span with random bytes in little-endian order. |
| Next | Generates the next double-precision floating-point number. |
| Next | Generates the next single-precision floating-point number. |
| Next | Generates the next 32-bit unsigned integer. |
| Next | Generates the next 64-bit unsigned integer. |
| Save | Saves the engine's state to the destination span in a stable little-endian format. |
| ToString | Returns the fully qualified type name of this instance. (Inherited from ValueType) |