Skip to main content

Class Sequencer

A sequence generator that can wrap. For example a 2 bit sequencer would generate the following numbers: 0,1,2,3,0,1,2,3,0,1,2,3...

Inheritance​
System.Object
Inherited Members​
Show
Syntax​
public class Sequencer

Constructors​

Sequencer(Int32)​

Declaration​
public Sequencer(int bits)
Parameters​
TypeNameDescription
System.Int32bitsamount of bits for the sequence

Properties​

Bits​

Number of bits used for the sequence generator up to 64

Declaration​
public int Bits { get; }

Methods​

Next()​

Generates the next value in the sequence starts with 0

Declaration​
public ulong Next()
Returns​
TypeDescription
System.UInt640, 1, 2, ..., (2^n)-1, 0, 1, 2, ...

NextAfter(UInt64)​

Gets the next sequence value after a given sequence wraps if necessary

Declaration​
public ulong NextAfter(ulong sequence)
Parameters​
TypeNameDescription
System.UInt64sequencecurrent sequence value
Returns​
TypeDescription
System.UInt64the next sequence value

MoveInBounds(UInt64)​

returns a sequence value from the given value wraps if necessary

Declaration​
public ulong MoveInBounds(ulong sequence)
Parameters​
TypeNameDescription
System.UInt64sequencecurrent sequence value
Returns​
TypeDescription
System.UInt64the next sequence value

Distance(UInt64, UInt64)​

Calculates the distance between 2 sequences, taking into account wrapping

Declaration​
public long Distance(ulong from, ulong to)
Parameters​
TypeNameDescription
System.UInt64fromcurrent sequence value
System.UInt64toprevious sequence value
Returns​
TypeDescription
System.Int64from - to, adjusted for wrapping

Reset()​

Declaration​
public void Reset()