Cha Cha Engine.Set Counter Method
Sets the counter to the specified value.
Definition
Namespace: Numerics.NET.Random.Engines
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.3.0
C#
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.3.0
public void SetCounter(
ReadOnlySpan<uint> counter
)Parameters
- counter ReadOnlySpan<UInt32>
- The new counter value. Length must exactly match CounterLength.
Implements
ICounterBased<T>.SetCounter(ReadOnlySpan<T>)Remarks
Setting the counter moves the generator to a specific position in the output sequence. This enables O(1) skip-ahead to arbitrary positions.
Consistency Protocol:
After calling SetCounter(ReadOnlySpan<T>), the engine enters an inconsistent state where the cached block does not correspond to the current key/counter coordinates. Callers must invoke GenerateBlock() before using any output mapping methods (Output(Int32) or Fill(Int32, Span<T>)). Invoking output methods while inconsistent results in undefined behavior.
Exceptions
| Argument | Thrown when counter.Length != CounterLength. |