Boost logo

Boost :

From: John E. Potter (jpotter_at_[hidden])
Date: 2000-01-09 06:00:55


On Sun, 9 Jan 2000, Aleksey Gurtovoy wrote:

> the current version is very simple and understandable - a point p1 is less
> than another point p2 if and only if it is located inside a rectangle
> (0,0) - (p2.x, p2.y).

Including two of the edges, ie. [0,0] - (p2.x, p2.y). Given p1 less
than p2 then p1 < p3 && p3 < p2 iff p3 is inside the box (p1) - (p2)
excluding all edges.

> If we change this definition to any other one which
> really induces a strict weak ordering on the points, we probably will have
> much more unclear definition. For example this implementation:
>
> template<class T1, class T2>
> bool operator <( const point<T1, T2>& p1, const point<T1, T2>& p2 ) {
> return p1.x() < p2.x() || ( p1.x() == p2.x() && p1.y() < p2.y() );
> }
>
> do induce a strict weak ordering on the points, but does it have a much
> sense besides a fact that it give us a correct behavior of sorting
> algorithms and some of std containers? I'm not sure.

P1 < p2 iff p1 is inside the box (0) - (p2) including three of the
edges. P1 < p3 && p3 < p2 iff p3 is in the box (p1) - (p2) including
three of the edges.

> So my question - do we need to change the definition of operator> for point
> and delta classes, or we want to introduce a special comparison function for
> situations I've described above?

Points in the plane are complex numbers. There is no algebraic less
for complex. Is there a meaningful geometric less for points? Note
that in the above, some verticies of the boxes do not match the rule.
The typo (>) above may be important. The set of points p such that
! (p < p1) && ! (p1 < p) is quite large.

John


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