p8mode
May 3rd, 2003, 06:39 PM
Hello.
I want to sort a multimap, based on the keys, among other things so that subsequent searching is efficienter. Isnt this possible? If so, whats wrong with the code below which tries to achieve this? Thanks very much in advance for any help.
Best Wishes,
p8mode
//---------------------------------------
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
typedef std::multimap<int, int> mimap;
typedef std::pair<int,int> ip;
//--------------
class Ftm // functor
{
public:
operator()(const ip& ip1, const ip &ip2) const
{
return ip1.first> ip2.first;
};
};
//--------------
void main()
{
mimap m;
m.insert(ip(i1, i1));
m.insert(ip(i1, i2));
m.insert(ip(i2, i3));
std::sort(m.begin(), m.end(), Ftm()); // error ?!
}
I want to sort a multimap, based on the keys, among other things so that subsequent searching is efficienter. Isnt this possible? If so, whats wrong with the code below which tries to achieve this? Thanks very much in advance for any help.
Best Wishes,
p8mode
//---------------------------------------
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
typedef std::multimap<int, int> mimap;
typedef std::pair<int,int> ip;
//--------------
class Ftm // functor
{
public:
operator()(const ip& ip1, const ip &ip2) const
{
return ip1.first> ip2.first;
};
};
//--------------
void main()
{
mimap m;
m.insert(ip(i1, i1));
m.insert(ip(i1, i2));
m.insert(ip(i2, i3));
std::sort(m.begin(), m.end(), Ftm()); // error ?!
}