InputRange for data structure without order?

Ali Çehreli acehreli at yahoo.com
Wed Jun 4 19:00:57 UTC 2025


On 6/4/25 4:10 AM, Monkyyy wrote:
 > On Wednesday, 4 June 2025 at 02:11:18 UTC, H. S. Teoh wrote:
 >> . But in general, containers should NOT be conflated with ranges. That
 >> only leads to wrong design.
 >>
 >> range should NOT mutate the container.  It should be regarded as
 >> something separate from the container.
 >
 > Not "general". It's a safety vs speed tradeoff. Immutable whatever's
 > data structure do just make allot of copies or allot of pointer overhead
 > and indirection.

I don't understand. Like H. S. Teoh said, a range over a container 
should not alter the container. I'm not aware of any data structure 
where that's not the case.

If a container has a way of accessing the elements (which it definitely 
has to because otherwise it's not really a container), then a 
light-weight range can be specified over the elements.

Ali



More information about the Digitalmars-d-learn mailing list