Re: to invalidate a range

2011-08-15 Thread Steven Schveighoffer
that they do not invalidate the ranges of their containers. What does it mean to invalidate a range? Say for example, you are iterating a red black tree, and your current front points at a certain node. Then that node is removed from the tree. That range is now invalid, because the node it points

Re: to invalidate a range

2011-08-15 Thread Steven Schveighoffer
and ranges don't tend to get invalidated as easily. As long as you don't remove the element (or elements in the case of a range - assuming that it keeps track of its two end points, as is likely) that it points to, then adding or removing elements from the container shouldn't invalidate

to invalidate a range

2011-08-12 Thread Ellery Newcomer
in std.container, the stable* container functions advocate that they do not invalidate the ranges of their containers. What does it mean to invalidate a range? my assumption is it means causing e.g. front or popFront to fail when empty says they should succeed or vice versa.

Re: to invalidate a range

2011-08-12 Thread bearophile
Ellery Newcomer: in std.container, the stable* container functions advocate that they do not invalidate the ranges of their containers. What does it mean to invalidate a range? Generally modifying a collection while you iterate on it causes troubles. When you iterate on a range and you

Re: to invalidate a range

2011-08-12 Thread Ellery Newcomer
On 08/12/2011 03:13 PM, bearophile wrote: Ellery Newcomer: in std.container, the stable* container functions advocate that they do not invalidate the ranges of their containers. What does it mean to invalidate a range? Generally modifying a collection while you iterate on it causes troubles

Re: to invalidate a range

2011-08-12 Thread Steven Schveighoffer
On Fri, 12 Aug 2011 15:54:53 -0400, Ellery Newcomer ellery-newco...@utulsa.edu wrote: in std.container, the stable* container functions advocate that they do not invalidate the ranges of their containers. What does it mean to invalidate a range? Say for example, you are iterating a red

Re: to invalidate a range

2011-08-12 Thread Ellery Newcomer
On 08/12/2011 03:29 PM, Steven Schveighoffer wrote: On Fri, 12 Aug 2011 15:54:53 -0400, Ellery Newcomer ellery-newco...@utulsa.edu wrote: in std.container, the stable* container functions advocate that they do not invalidate the ranges of their containers. What does it mean to invalidate

Re: to invalidate a range

2011-08-12 Thread Ellery Newcomer
(or elements in the case of a range - assuming that it keeps track of its two end points, as is likely) that it points to, then adding or removing elements from the container shouldn't invalidate the iterator/range. shouldn't isn't a guarantee. Where there is shouldn't, there can't be stableRemove

Re: to invalidate a range

2011-08-12 Thread Jonathan M Davis
invalidated as easily. As long as you don't remove the element (or elements in the case of a range - assuming that it keeps track of its two end points, as is likely) that it points to, then adding or removing elements from the container shouldn't invalidate the iterator/range. shouldn't isn't

Re: to invalidate a range

2011-08-12 Thread Ellery Newcomer
On 08/12/2011 05:51 PM, Jonathan M Davis wrote: An implementation can guarantee it as long as your range doesn't directly point to an element being removed (i.e. as long as the element isn't on the ends - or maybe one past the end, depending on the implementation). But _no_ container can

Re: to invalidate a range

2011-08-12 Thread Jonathan M Davis
On Friday, August 12, 2011 16:16 Ellery Newcomer wrote: On 08/12/2011 05:51 PM, Jonathan M Davis wrote: An implementation can guarantee it as long as your range doesn't directly point to an element being removed (i.e. as long as the element isn't on the ends - or maybe one past the end,

Re: to invalidate a range

2011-08-12 Thread Ellery Newcomer
in the container. This means that removing any node could potentially invalidate a range somewhere. When such a conflict arises, you cannot both perform the removal and keep a valid range, regardless of whether you even knew of the conflict.

Re: to invalidate a range

2011-08-12 Thread Jonathan M Davis
it, in a node based container, [I expect] will be a pointer to a node, which might point to any node in the container. This means that removing any node could potentially invalidate a range somewhere. When such a conflict arises, you cannot both perform the removal and keep a valid range, regardless