BinaryHeap is a range so it goes in std.range. Agree?

Simen kjaeraas simen.kjaras at gmail.com
Tue Jun 8 08:53:06 PDT 2010


Andrei Alexandrescu <SeeWebsiteForEmail at erdani.org> wrote:

> Let me be more specific: BinaryHeap does not work like a range. It _is_  
> a range. It implements all of a forward range's primitives with the  
> required semantics.

Is not anything that works like a range automatically a range?

> But where should I put it then? I thought it would be even more  
> confusing if I put something in std.container that wait a minute, is not  
> a container.

How is it not a container? Because it uses a different container as a
back-end?

> Generally, a range with benefits (i.e. extra functions) is still a range
> if it implements the required range primitives with the required
> semantics.

So many containers are ranges, then. And we will see this question for
any of those containers added to Phobos. Or we decide on some rules to
disambiguate between the two, and follow those.

I hold that a range is a view that does not change the underlying data,
and does not store all its data.
That makes an array a container, which I feel is correct. It may still
have range functionality, and thus be both, but it should be
categorized as a container first.

Are there other ranges that violate this definition?

-- 
Simen


More information about the Digitalmars-d mailing list