Thread overview
Implementing iterators for D custom data structures (best practices)
Oct 17, 2011
Granville Barnett
Oct 17, 2011
Jonathan M Davis
Oct 17, 2011
Granville Barnett
Oct 17, 2011
deadalnix
October 17, 2011
Hi All,

I've not used D for long so hopefully this question isn't too stupid...

Are there any best practices for implementing iterators in D? My understanding is that D follows a similar design approach to the STL RE containers - iterators - algs - adapters etc.

Also, are there any examples of well written data structures that expose iterators?...I recall that in D only arrays have them (I may be wrong, I haven't looked). Any open source projects that are notoriously well implemented?

Thanks in advance.

GB
October 17, 2011
On Monday, October 17, 2011 10:22:42 Granville Barnett wrote:
> Hi All,
> 
> I've not used D for long so hopefully this question isn't too stupid...
> 
> Are there any best practices for implementing iterators in D? My understanding is that D follows a similar design approach to the STL RE containers - iterators - algs - adapters etc.
> 
> Also, are there any examples of well written data structures that expose iterators?...I recall that in D only arrays have them (I may be wrong, I haven't looked). Any open source projects that are notoriously well implemented?
> 
> Thanks in advance.

D code doesn't normally use iterators. It uses ranges, which are a similar but generally superior concept.

http://www.informit.com/articles/printerfriendly.aspx?p=1407357

std.range and std.algorithm in particular make heavy use of ranges:

http://d-programming-language.org/phobos/std_range.html http://d-programming-language.org/phobos/std_algorithm.html

- Jonathan M Davis
October 17, 2011
On 17/10/2011 10:55, Jonathan M Davis wrote:
> On Monday, October 17, 2011 10:22:42 Granville Barnett wrote:
>> Hi All,
>>
>> I've not used D for long so hopefully this question isn't too stupid...
>>
>> Are there any best practices for implementing iterators in D? My
>> understanding is that D follows a similar design approach to the STL RE
>> containers - iterators - algs - adapters etc.
>>
>> Also, are there any examples of well written data structures that expose
>> iterators?...I recall that in D only arrays have them (I may be wrong, I
>> haven't looked). Any open source projects that are notoriously well
>> implemented?
>>
>> Thanks in advance.
>
> D code doesn't normally use iterators. It uses ranges, which are a similar but
> generally superior concept.
>
> http://www.informit.com/articles/printerfriendly.aspx?p=1407357
>
> std.range and std.algorithm in particular make heavy use of ranges:
>
> http://d-programming-language.org/phobos/std_range.html
> http://d-programming-language.org/phobos/std_algorithm.html
>
> - Jonathan M Davis

Thanks Jonathan, I'll take a look.

GB
October 17, 2011
In addition, I would like to mention this confrence by Andrei Alexandrescu : http://blip.tv/boostcon/boostcon-2009-keynote-2452140

Le 17/10/2011 04:55, Jonathan M Davis a écrit :
> On Monday, October 17, 2011 10:22:42 Granville Barnett wrote:
>> Hi All,
>>
>> I've not used D for long so hopefully this question isn't too stupid...
>>
>> Are there any best practices for implementing iterators in D? My
>> understanding is that D follows a similar design approach to the STL RE
>> containers - iterators - algs - adapters etc.
>>
>> Also, are there any examples of well written data structures that expose
>> iterators?...I recall that in D only arrays have them (I may be wrong, I
>> haven't looked). Any open source projects that are notoriously well
>> implemented?
>>
>> Thanks in advance.
>
> D code doesn't normally use iterators. It uses ranges, which are a similar but
> generally superior concept.
>
> http://www.informit.com/articles/printerfriendly.aspx?p=1407357
>
> std.range and std.algorithm in particular make heavy use of ranges:
>
> http://d-programming-language.org/phobos/std_range.html
> http://d-programming-language.org/phobos/std_algorithm.html
>
> - Jonathan M Davis