Please, look for the line marked +++
This is a structure with a public property returning a (still unsorted) range built on-the-fly from already-set properties, a basic range from a to z with n step where some specific values can be added in-between. The range is a float which I am currently using for currency (horrible) and later plan to move it to decimal 10 or the like.
public struct gudtRangeWhatIf {
private float[] pnumValueCustom;
private float pnumValueBaseLimit1;
private float pnumValueBaseLimit2;
private float pnumValueBaseStep;
public float start() @property const { return pnumValueBaseLimit1; }
public float end() @property const { return pnumValueBaseLimit2; }
public float step() @property const { return pnumValueBaseStep; }
public float[] range() @property const {
float[] lnumRange;
if (! (pnumValueBaseLimit1 == float.nan || pnumValueBaseLimit2 == float.nan || pnumValueBaseStep == float.nan)) {
for (
float lnumValue = pnumValueBaseLimit1;
lnumValue <= pnumValueBaseLimit2;
lnumValue += pnumValueBaseStep
) {
lnumRange ~= lnumValue;
}
}
foreach (float lnumValue; pnumValueCustom) {
lnumRange ~= lnumValue;
}
return lnumRange; /// .sort!(r"a > b"c); /// doesn't work +++
}
this(
in float lnumValueBaseLimit1,
in float lnumValueBaseLimit2,
in float lnumValueBaseStep
) {
/// (1) given start limit > 0
/// (2) given end limit > start limit
/// (3) given step > 0
if (lnumValueBaseLimit1 > 0f && lnumValueBaseLimit1 < lnumValueBaseLimit2 && lnumValueBaseStep > 0f) {
pnumValueBaseLimit1 = lnumValueBaseLimit1;
pnumValueBaseLimit2 = lnumValueBaseLimit2;
pnumValueBaseStep = lnumValueBaseStep;
}
}
public void addCustomValue(
in float lnumValue
) {
/// (1) given value > 0
if (lnumValue > 0f) {
pnumValueCustom ~= lnumValue;
}
}
}