I would like to have a composite key for a multi index container of boost and would like to have a static comparator function passed to it (something like the code below). I also would like to avoid the solution given here to avoid the overhead of creating stack objects upon comparing every two elements as I'm working with a huge amounts of data.
bool func(const foo& lhs, const foo& rhs) {
if (lhs.count >= lhs.threshold && rhs.count < rhs.threshold ||
lhs.count < lhs.threshold && rhs.count >= rhs.threshold) {
return lhs.count < lhs.threshold;
} else if (lhs.time != rhs.time) {
return lhs.time < rhs.time;
} else {
return lhs.count < rhs.count;
}
}
typedef boost::multi_index_container<
foo,
boost::multi_index::indexed_by<
boost::multi_index::ordered_unique<
boost::multi_index::composite_key<foo, member, member>,
func
>
>
> MultiIndexSet;