Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » SortedIndex and Less
SortedIndex and Less [message #40728] Tue, 10 September 2013 17:34 Go to previous message
keltor is currently offline  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
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Deserialize json object
Next Topic: Confused about ArrayCtrl
Goto Forum:
  


Current Time: Mon Apr 29 11:01:34 CEST 2024

Total time taken to generate the page: 0.02224 seconds