The OpenD Programming Language

group

Groups data by colour label etc.

Will also add DefaultValues for label etc to the data. It is also possible to specify exactly what to group by on as a template parameter. See example.

template group(Specs...)
group
(
AES
)
(
AES aes
)

Examples

import std.range : walkLength;
auto aes = Aes!(double[], "x", string[], "colour", double[], "alpha")
    ([0.0,1,2,3], ["a","a","b","b"], [0.0,1,0,1]);

assertEqual(group!("colour","alpha")(aes).walkLength,4);
assertEqual(group!("alpha")(aes).walkLength,2);

// Ignores field that does not exist
assertEqual(group!("alpha","abcdef")(aes).walkLength,2);

// Should return one group holding them all
assertEqual(group!("abcdef")(aes)[0].walkLength,4);

assertEqual(group(aes).walkLength,4);
auto aes = Aes!(double[], "x", double[], "y", string[], "colour")([1.0,
    2.0, 1.1], [3.0, 1.5, 1.1], ["a", "b", "a"]);

import std.range : walkLength, front, popFront;

auto grouped = aes.group;
assertEqual(grouped.walkLength, 2);
size_t totalLength = grouped.front.walkLength;
assertGreaterThan(totalLength, 0);
assertLessThan(totalLength, 3);
grouped.popFront;
assertEqual(totalLength + grouped.front.walkLength, 3);

Meta