Function Enumap.byValue

Get a range iterating over the stored values.

Prototype

{null} byValue();

Example

you can use byValue to perform range based operations on the values:

import std.range     : iota;
import std.algorithm : map, equal;

const Enumap!(Element, int) e1 = iota(0, 4);
const Enumap!(Element, int) e2 = e1.byValue.map!(x => x + 2);
assert(e2.byValue.equal(iota(2, 6)));

Example

byValue supports ref access:

with (Element) {
  auto elements = enumap(air, 1, water, 2, fire, 3, earth, 4);
  foreach(ref val ; elements.byValue) ++val;
  assert(elements == enumap(air, 2, water, 3, fire, 4, earth, 5));
}

Authors

Ryan Roden-Corrent (rcorre)

Copyright

© 2015, Ryan Roden-Corrent

License

MIT