定义了一个双关键字的 multiset,按双关键字升序排序,但如果集合中没有第一关键字为 a 的元素,我对其二分找 a,−1 时他却返回了一个形如 a,0 的元素
(语文太差了描述不清问题,具体看代码)
struct pr1
{
int c,v;
friend bool operator<(pr1 x,pr1 y)
{
if(x.c==y.c) return x.v<y.v;
return x.c<y.c;
}
};
multiset<pr1> s1[100];
int main()
{
int p=1;s1[p].clear(); s1[p].insert(pr1{1,36254}); s1[p].insert(pr1{1,532100});
auto kk=s1[p].lower_bound(pr1{2,-1});
//no 2 appeared
cout<<kk->c<<" "<<kk->v<<"\n";
//but the output is {2,0}
return 0;
}
这段代码输出为 2,0,但该集合中并没有这个元素