Comparator

Discussion in 'C++' started by bil050, Dec 19, 2010.

  1. bil050

    bil050 Guest

    Hi,
    I have defined suc a comparator class
    Code (Text):

    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
     
    bil050, Dec 19, 2010
    #1
    1. Advertisements

  2. On 12/19/2010 11:10 AM, bil050 wrote:
    > Hi,
    > I have defined suc a comparator class
    >
    Code (Text):

    > 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
     
    Victor Bazarov, Dec 20, 2010
    #2
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Valentin Tihomirov

    flags vs. comparator

    Valentin Tihomirov, Nov 10, 2003, in forum: VHDL
    Replies:
    5
    Views:
    790
    Valentin Tihomirov
    Nov 11, 2003
  2. sunil
    Replies:
    4
    Views:
    909
    Ralf Hildebrandt
    Feb 22, 2004
  3. sk

    comparator problem

    sk, Nov 3, 2004, in forum: VHDL
    Replies:
    0
    Views:
    938
  4. john

    counter plus comparator

    john, Nov 8, 2004, in forum: VHDL
    Replies:
    4
    Views:
    923
    Raghavendra
    Nov 10, 2004
  5. Replies:
    6
    Views:
    616
Loading...

Share This Page