I want to define a map like:
#include<map>
struct key{
vector<int> start_idx;
vector<int> len;
};
map<key, int> m;
I looked at other questions and found that I could write the comparison function like this
struct Class1Compare
{
bool operator() (const key1& lhs, const key2& rhs) const
{
.....
}
};
In fact, start_idx means a start index in a file, len means length, so I need to use other parameter in the comparsion function like:
bool operator() (const key1& lhs, const key2& rhs) const
{
... //in this field, i can use (char *file).
}
and char *file may not be global, because I use multi-thread which means in different thread, char *file is different.