Re: InsertBefore in DList of structs

2019-03-05 Thread r-const-dev via Digitalmars-d-learn
On Tuesday, 5 March 2019 at 08:39:56 UTC, drug wrote: On 05.03.2019 2:01, r-const-dev wrote: [...] dataPoints is an aggregate type variable, not a range and slice operator opSlice/[] returns a range of this aggregate type. I have no appropriate links unfortunately but these can be useful http

Re: InsertBefore in DList of structs

2019-03-05 Thread drug via Digitalmars-d-learn
On 05.03.2019 2:01, r-const-dev wrote: Thanks, seems that using dataPoints[] makes dataPoints usable as an range. How can I learn more about [] operator? I'm not sure I understand how is this documented in DList. dataPoints is an aggregate type variable, not a range and slice operator opSlice

Re: InsertBefore in DList of structs

2019-03-04 Thread r-const-dev via Digitalmars-d-learn
On Monday, 4 March 2019 at 10:09:19 UTC, drug wrote: 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

Re: InsertBefore in DList of structs

2019-03-04 Thread drug via Digitalmars-d-learn
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 DataP

Re: InsertBefore in DList of structs

2019-03-04 Thread drug via Digitalmars-d-learn
On 04.03.2019 11:14, r-const-dev wrote: I have a DList of structs, DataPoint, ordered by a struct field, time. I'm trying to insert a new entry preserving order, so I'm trying to use `until` to find the insertion point and `insertBefore` with the result. struct DataPoint {     immutable ulong