On 2010-03-05 16:09:08 -0500, Andrei Alexandrescu <[email protected]> said:

A range is a view on a container. As such, popping off a range does not affect the topology of the underlying container. Consider, for contrast, a balanced binary tree. Removing an element triggers a rebalance of the tree, but popping an element off an iterator in that tree does not affect the tree itself.

Fair enough?

That's a fine definition, except for the word "topology".

Whether it changes the topology should be an implementation detail. Popping of a C++ vector or a hash table doesn't change the topology, will you make them ranges? That doesn't make much sense.

Also, do you consider that popping off a stream affects its topology? If your stream is buffered, you're probably advancing a pointer through a buffer with 'pop', and deallocating old buffers from time to time. So this definition would forbid a stream from being a range. That doesn't make much sense.

And similarly you could have a queue container where you insert things at the back and pop things from the front. But that's basically the same thing as a stream. Is a queue a container or a range?

I think this definition is more on the spot: a range is something you consume, a container is something used to hold data. Those definition are not mutually exclusive, but is this really a problem?


--
Michel Fortin
[email protected]
http://michelf.com/

Reply via email to