Boost logo

Boost :

From: Daryle Walker (darylew_at_[hidden])
Date: 2001-09-26 23:23:13


on 9/26/01 11:42 AM, Jeremy Siek at jsiek_at_[hidden] wrote:

> On Wed, 26 Sep 2001, David Abrahams wrote:
>
> david.>
> david.> ----- Original Message -----
> david.> From: "Daryle Walker" <darylew_at_[hidden]>
> david.>
> david.> > Did you guys notice that I made iterator comparison partially
> david.> > ordered? (It was originally
> david.> > totally ordered.) You shouldn't compare iterators from two
> david.> > different containers.
> david.>
> david.> Hmm. No, I didn't notice such a change... Thanks for
> david.> pointing it out. Actually, I'm not sure it's an
> david.> appropriate change. What does the comparison between
> david.> iterators from different sequences have to do with partial
> david.> ordering? Iterators which can be compared always form a
> david.> total order, AFAIK. Why should we choose the
> david.> less-efficient implementation?
>
> I agree, it should be a total ordering, which still does not mean you can
> compare iterator from different containers, each container is its own
> universe. It just means that there is a total ordering for all iterators
> pointing into the same container.

You guys are seeing total v. partial ordering as a local thing, I see it as
a global thing. Think about the IEEE floating point numbers; usually any
pair of numbers you compare are going to be ordered, so a total ordering
evaluation will work. However there is one valid value that is not ordered,
NaN, so the IEEE numbers are globally only partially ordered.

In most circumstances, the iterators you compare will be from the same
container, so a total ordering seems to work. But if you get two arbitrary,
yet valid, iterators, their comparisons (besides not-equal) should be FALSE
because you don't know if the iterators use the same container. So
iterators are globally partially ordered. An alternative would be to
declare potential cross-container comparisons as undefined. Shouldn't we
give the user a nicer response?

-- 
Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT mac DOT com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk