Class BinAttribute<T>
Lightweight attribute wrapper representing a value that is stored
in a single integer attribute, encoded in binary using a subset of bits.
A standard int
has 32 bits, which can be used to encode multiple
different values, especially since amoebot memory is limited and will
never use integer values this large.
Inheritance
Namespace: AS2.Subroutines.BinStateHelpers
Assembly: .dll
Syntax
public abstract class BinAttribute<T>
Type Parameters
Name | Description |
---|---|
T | The type of value represented by the attribute. |
Constructors
| Edit this page View SourceBinAttribute(ParticleAttribute<int>, int)
Creates a new attribute wrapper referencing the given state attribute int.
Declaration
public BinAttribute(ParticleAttribute<int> attr, int idx)
Parameters
Type | Name | Description |
---|---|---|
ParticleAttribute<int> | attr | The attribute storing the integer that contains this value as a subset of bits. |
int | idx | The bit index at which the encoding of this value starts. |
Fields
| Edit this page View Sourceattr
Declaration
public readonly ParticleAttribute<int> attr
Field Value
Type | Description |
---|---|
ParticleAttribute<int> |
idx
Declaration
public readonly int idx
Field Value
Type | Description |
---|---|
int |
Methods
| Edit this page View SourceGetCurrentValue()
Returns the latest value.
Declaration
public abstract T GetCurrentValue()
Returns
Type | Description |
---|---|
T | The value decoded from the int's latest value. |
GetValue()
Returns the value from the beginning of the current round.
Declaration
public abstract T GetValue()
Returns
Type | Description |
---|---|
T | The value decoded from the int's snapshot value. |
SetValue(T)
Writes a new value to the state integer.
Declaration
public abstract void SetValue(T value)
Parameters
Type | Name | Description |
---|---|---|
T | value | The new value to be written. |