Thread: sort vector of vectors by their size

  1. #1
    Registered User
    Join Date
    Jan 2011
    Posts
    222

    sort vector of vectors by their size

    Hi,

    I have a problem with compiling the following situation:

    I have a class in which there is a comparison function:

    Code:
    template <typename Tint>
    bool CMC<Tint>::CmpVec(const vector<Tint>& a, const vector<Tint>& b) {
       return a.size() > b.size();
    }

    in another function (member of the same class) I am calling sort function:


    Code:
    template <typename Tint>
    void CMC<Tint>::Clique(Tint perc){
       
       vector<vector<Tint>> CClique ;
     
      //  Fill CClique
    
       sort(CClique.begin(),CClique.end(),CmpVec());    // her there is an  error: no matching function for call to ‘CMC<long>::CmpVec() note: candidate is:
    ../../../src/include/CMC/CMC.hpp:89:6: note: bool CMC<Tint>::CmpVec(const std::vector<_RealType>&, const std::vector<_RealType>&)
    
    ...
    }
    Can anyone help ?

    b

  2. #2
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    O_o

    You have had the same problem wearing a different mask.

    Soma
    “Salem Was Wrong!” -- Pedant Necromancer
    “Four isn't random!” -- Gibbering Mouther

  3. #3
    Registered User
    Join Date
    Jan 2011
    Posts
    222
    Quote Originally Posted by phantomotap View Post
    O_o

    You have had the same problem wearing a different mask.

    Soma


    totally forgot .... sorry sorry sorry !!!!

    add:

    Once more sorry. I had this fealing that I had a similar situation before but I could not remember when and where. I trully did not mean to wast anyones time on reading this post. And yes the last time your posts (all of who posted ) helped solving my issue. However it tottaly slipped my mind. Thnx and sorry once more. I'll do a better job using the search engine before posting next time.
    Last edited by baxy; 05-02-2015 at 04:28 AM.

  4. #4
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Everyone makes mistakes... don't beat yourself up for it.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 09-22-2013, 07:00 AM
  2. Vector Of Vectors
    By Khadafi in forum C++ Programming
    Replies: 11
    Last Post: 12-30-2011, 12:04 PM
  3. Sort two vectors in the same order
    By jw232 in forum C++ Programming
    Replies: 2
    Last Post: 03-08-2008, 05:49 PM
  4. vector of vectors
    By xddxogm3 in forum C++ Programming
    Replies: 11
    Last Post: 05-04-2007, 10:25 AM
  5. Vector of Vectors
    By swanley007 in forum C++ Programming
    Replies: 2
    Last Post: 03-31-2006, 04:33 PM