No, Saturn is most definitely correct. It is most definitely _not_ a bug. You've already established that A < B is false and B < A is false for A=(100, 0, 30) and B=(20, 0, 110). So, given these two vectors, how do you sort them? Does A come first or B?
If you don't define a strict ordering, then sort doesn't work. Here is a simple testcase.
Code: Select all
#include <vector3d.h>
#include <irrarray.h>
#include <assert.h>
#include <stdio.h>
using namespace irr;
void show(const core::array<core::vector3df>& a)
{
u32 i;
for (i = 0; i < a.size(); ++i)
printf ("X=%f Y=%f Z=%f\n", a[i].X, a[i].Y, a[i].Z);
printf ("\n");
}
int main ()
{
core::array<core::vector3df> a;
u32 i;
for (i = 0; i < 3; ++i)
a.push_back (core::vector3df(i, 0, 3 - i));
show (a);
a.sort ();
show (a);
for (i = 0; i < a.size() - 1; ++i)
assert (a[i] < a[i+1] || a[i] == a[i+1]);
return 0;
}
So now that you know that you can't sort a type that doesn't define a strict weak ordering, how do you expect to do a binary search?
Travis