Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Comparator

Reply
Thread Tools

Comparator

 
 
bil050
Guest
Posts: n/a
 
      12-19-2010
Hi,
I have defined suc a comparator class
Code:
lass FComapare
{
public:
	FComapare(size_t p):m_p(p){};
	bool operator() (Node *lId,Node* rId)
	{
		if(lId->getDiff(m_p) < rId->getDiff(m_p))
			return true;
		else if(lId->getDiff(m_p) == rId->getDiff(m_p))
		{
			if(lId->getLT() < rId->getLT())
				return true;
			return false;
		}
	}
private:
	size_t m_p;
};
I want to create vector of sets while the comarator for each set is
created as FComapare object with differnt paremeter.
How can I do it?
Thanks
 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      12-20-2010
On 12/19/2010 11:10 AM, bil050 wrote:
> Hi,
> I have defined suc a comparator class
>
Code:
> lass FComapare
> {
> public:
> 	FComapare(size_t p):m_p(p){};
> 	bool operator() (Node *lId,Node* rId)
> 	{
> 		if(lId->getDiff(m_p)<  rId->getDiff(m_p))
> 			return true;
> 		else if(lId->getDiff(m_p) == rId->getDiff(m_p))
> 		{
> 			if(lId->getLT()<  rId->getLT())
> 				return true;
> 			return false;
> 		}
> 	}
> private:
> 	size_t m_p;
> };
>
> I want to create vector of sets while the comarator for each set is
> created as FComapare object with differnt paremeter.
> How can I do it?


What's the problem? To create a vector you simply define one. A vector
of sets? Sure:

std::vector<std::set< ... > > vector_of_sets;

But you didn't give us enough to go on. What's "Node"? What is the set
going to be of? Consider giving it a shot yourself first. We do not do
anybody's homework, and your post sounds too much like one.

V
--
I do not respond to top-posted replies, please don't ask
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Optimized comparator ALuPin@web.de VHDL 6 08-25-2005 08:45 AM
counter plus comparator john VHDL 4 11-10-2004 05:41 AM
comparator problem sk VHDL 0 11-03-2004 07:12 PM
Comparator and minimum value address sunil VHDL 4 02-22-2004 08:10 PM
flags vs. comparator Valentin Tihomirov VHDL 5 11-11-2003 05:16 PM



Advertisments