我想在set<Foo, FooComp>
中进行唯一和订购。C++设置唯一和订单
在下面的代码中,我想要一个唯一的,并按b和c排序。 所以,没有相同的foo.a
和订购foo.b
和foo.c
。
我该怎么做?
struct Foo {
int a, b, c;
Foo(int a, int b, int c) : a(a), b(b), c(c) {}
}
struct FooComp {
bool operator() (const Foo& f, const Foo& s) const {
if (f.pattern == s.pattern) {
return false;
}
if (f.start == s.start) {
return f.length < s.length;
}
return f.start < s.start;
}
}
还是我使用其他的STL或数据结构?
,我想使用的地图,'了'关键和'(B,C)'的值。但是,地图不是为这种情况设计的(我认为)。 – Maybe