On 04.03.2019 13:03, drug wrote:
insertStable needs DList.Range, not Until!... one. You can do something like this https://run.dlang.io/is/A2vZjW
Oops, it was wrong example, I'd recommend this way - https://run.dlang.io/is/ugPL8j
```
import std.algorithm, std.container, std.stdio;

struct DataPoint {
    immutable ulong time;
    ulong value;
}

void main() {
    auto dataPoints = DList!DataPoint([
        DataPoint(10_000_000, 1),
        DataPoint(30_000_000, 3),
        DataPoint(40_000_000, 4),
    ]);

    auto time = 30_000_000;
    auto r = findSplit!((a, b) => a.time == b)(dataPoints[], [time]);

    auto dp = dataPoints[].find(r[1].front);
    writeln("before: ", dataPoints[]);
    dataPoints.insertBefore(dp, DataPoint(20_000_000, 2));
    writeln("after: ", dataPoints[]);
}

```

Reply via email to