Struct Enumap
A structure that maps each member of an enum to a single value.
An
is a lightweight alternative to an associative array that is
useable when your key type is an enum.
Enumap
It provides some added benefits over the AA, such as array-wise operations,
default values for all keys, and some nice
based syntactic
sugar for element access.
opDispatch
The key enum must be backed by an integral type and have 'default' numbering. The backing value must start at 0 and grows by 1 for each member.
Constructors
Name | Description |
---|---|
this
|
Construct an Enumap from a static array.
|
Methods
Name | Description |
---|---|
byKey
|
Get a range iterating over the members of the enum K .
|
byKeyValue
|
Return a range of (EnumMember, value) pairs. |
byValue
|
Get a range iterating over the stored values. |
opApply
|
Execute a foreach statement over (EnumMember, value) pairs. |
opApply
|
Execute foreach over (EnumMember, ref value) pairs to modify elements. |
opIndex
|
Access the value at the index specified by an enum member. |
Templates
Name | Description |
---|---|
opAssign
|
An Enumap can be assigned from an array or range of values
|
opBinary
|
Apply an array-wise operation between two s.
|
opDispatch
|
Access the value at the index specified by the name of an enum member. |
opOpAssign
|
Perform an in-place operation. |
opUnary
|
Perform a unary operation on each entry. |
this
|
Assign from a range with a number of elements exactly matching .
|
Parameters
Name | Description |
---|---|
K | The type of enum used as a key. The enum values must start at 0, and increase by 1 for each entry. |
V | The type of value stored for each enum member |
Authors
Ryan Roden-Corrent (rcorre)
Copyright
© 2015, Ryan Roden-Corrent
License
MIT