InsertBefore in DList of structs

drug drug2004 at bk.ru
Tue Mar 5 08:39:56 UTC 2019


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/[] returns a range of this aggregate type. I have no appropriate 
links unfortunately but these can be useful
https://dlang.org/phobos/std_container_dlist.html#.DList.opSlice - this 
operator returns a range
https://dlang.org/phobos/std_container_dlist.html#.DList.Range - this is 
  range that allows to iterate over DList elements
http://ddili.org/ders/d.en/ranges.html - intro to ranges
> 
> Find does the job! What's the difference between find and until?
`find` returns a range that starts from the key
`until` returns a range of all elements before the key
https://run.dlang.io/is/1kpOUx

P.S. `findSplit` returns three ranges, first one contains all elements 
before the key like `until`, second range contains all elements that are 
equal to the key and third range contains the rest



More information about the Digitalmars-d-learn mailing list