sorting with std::map

Discussion in 'C++' started by A. Saksena, Feb 2, 2005.

  1. A. Saksena

    A. Saksena Guest

    Hi guys,
    Question regrading std::map. If I have a std::map like
    std::map < unsigned int, SOME_USER_DEFINED_DATA_TYPE > request_map;
    how I can sort this request_map for given value of unsigned int.
    I have a understanding that STL sort algorithm cannot be used with a
    associative containers like map.Is there is any other way?

    Abhishek
     
    A. Saksena, Feb 2, 2005
    #1
    1. Advertising

  2. A. Saksena

    David Harmon Guest

    On Wed, 2 Feb 2005 11:30:56 +0100 in comp.lang.c++, " A. Saksena"
    <> wrote,
    >Hi guys,
    >Question regrading std::map. If I have a std::map like
    >std::map < unsigned int, SOME_USER_DEFINED_DATA_TYPE > request_map;
    >how I can sort this request_map for given value of unsigned int.


    A std::map always sorts itself according to the predicate you created
    it with (default std::less<T>). It's speedy key lookup depends on
    that. You cannot sort it differently later.

    What does "sort for a given value" mean, anyway?
     
    David Harmon, Feb 2, 2005
    #2
    1. Advertising

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. Peter Jansson
    Replies:
    5
    Views:
    6,359
    Ivan Vecerina
    Mar 17, 2005
  2. Gernot Frisch
    Replies:
    2
    Views:
    407
    Gernot Frisch
    Feb 1, 2006
  3. Replies:
    1
    Views:
    436
    red floyd
    Dec 21, 2008
  4. Thomas J. Gritzan
    Replies:
    6
    Views:
    1,034
    James Kanze
    Dec 22, 2008
  5. James Kanze
    Replies:
    0
    Views:
    2,034
    James Kanze
    Dec 21, 2008
Loading...

Share This Page