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
Re: SortedIndex and Less [message #40863 is a reply to message #40728] Wed, 25 September 2013 08:12 Go to previous messageGo to previous message
keltor is currently offline  keltor
Messages: 73
Registered: February 2012
Member
OK, sorry. But really all I did was to add that line to the bottom of your code. Here's the full program:

#include <Core/Core.h>

using namespace Upp;

struct rho : Moveable<rho> {
	int x,y,z;

	rho(int x,int y,int z) : x(x), y(y), z(z) {}
	rho() {}
	
	String ToString() const { return AsString(x) + ' ' + AsString(y) + ' ' + AsString(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;
}

CONSOLE_APP_MAIN{
	StdLogSetup(LOG_FILE);

	SortedIndex<rho> data;
	data.Add(rho(1, 2, 3));
	data.Add(rho(1, 1, 1));
	data.Add(rho(1, 2, 0));
	data.FindAdd(rho(1, 2, 3));

	DDUMPC(data);
}


Thanks for the help Mirek

[Updated on: Wed, 25 September 2013 08:27]

Report message to a moderator

 
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: Wed May 15 09:36:35 CEST 2024

Total time taken to generate the page: 0.02210 seconds