mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
19 lines
511 B
C
19 lines
511 B
C
module std::collections::enummap<Enum, ValueType>;
|
|
|
|
struct EnumMap
|
|
{
|
|
ValueType[Enum.len] values;
|
|
}
|
|
|
|
fn void EnumMap.init(EnumMap* this, ValueType init_value)
|
|
{
|
|
foreach(&a : this.values)
|
|
{
|
|
*a = init_value;
|
|
}
|
|
}
|
|
|
|
fn uint EnumMap.len(EnumMap* this) @operator(len) => this.values.len;
|
|
fn ValueType EnumMap.get(EnumMap* this, Enum key) @operator([]) => this.values[key.ordinal];
|
|
fn void EnumMap.set(EnumMap* this, Enum key, ValueType value) @operator([]=) => this.values[key.ordinal] = value;
|