Home » Community » Newbie corner » SortedIndex and Less
SortedIndex and Less [message #40728] |
Tue, 10 September 2013 17:34 |
keltor
Messages: 73 Registered: February 2012
|
Member |
|
|
Hey there,
I am finally stepping into NTL and so far I like it a lot, much nicer than STL, I think. I have encountered a hurdle though.
I would like to sort a class. I provide what I thought was enough data to appease the NTL gods, but it seems I need some more stuff.
Here's a sample of my simple test program:
struct rho : Moveable<rho> {
int x,y,z;
rho(int x,int y,int z) : x(x), y(y), z(z) {}
rho() {}
}r;
unsigned GetHashValue(const rho& p)
{
return CombineHash(p.x, p.x, p.z);
}
bool operator==(const rho& a, const rho& b)
{
return a.x == b.x && a.y == b.y && a.z == b.z;
}
bool operator < (const rho& a, const rho& b){
return a.x == b.x ? (a.y == b.y ? a.z < b.z : a.y < b.y) : a.x < b.x;
}
Index<rho> works fine (without the operator < part), but SortedIndex<rho> does not. I looked at the StdLess<T> code and it seems that all it does is to provide a simple return a < b operation. What am I missing?
Thanks,
Kel
|
|
|
Goto Forum:
Current Time: Tue Jan 21 09:30:03 CET 2025
Total time taken to generate the page: 0.01550 seconds
|