D Ranges in C#
bearophile
bearophileHUGS at lycos.com
Sat Jun 1 01:11:59 PDT 2013
David Piepgrass:
> http://loyc-etc.blogspot.ca/2013/06/d-style-ranges-in-c-net.html
From the article:
>Ranges are an improvement on the C++ concept of iterators. I
>don't exactly know how ranges were invented in D, but perhaps
>someone noticed that most of the C++ STL algorithms require
>pairs of iterators:<
Ranges are an improvement over iterators about as much as oxygen
molecules are an "improvement" over oxygen atoms. You breath
mostly O2, and it allows you to live, but they are made of atomic
oxygen. Atomic oxygen is more fundamental, it is here to stay (as
Alexander Stepanov says), and it has "capabilities" that
molecules don't have. In your normal life you can think to use
only molecular oxygen, but sometimes you can even desire some
ozone :-) And in chemistry reactions that happen inside you all
the time, like oxidation, the oxygen molecules usually break
apart to react.
>In fact, most STL algorithms require exactly two iterators--a
>range--and none require only a single iterator<
I think there are some C++ data structures that store many single
iterators. If you instead store ranges you double the data amount.
Bye,
bearophile
More information about the Digitalmars-d
mailing list