J
JDT
Hi,
The last statement at the end of this post is to delete a set member
7.7. I set a break point inside ltstr:perator(). I found out that
STL binary-seach the set twice. How come? I have another problem that
a member in a set cannot be deleted. I think I may be able to solve
that problem if I can figure out the problem posted here. Thanks for
your help.
The sequence of (f1, f2) STL goes through is (7.7, 4.4), (7.7, 6.6),
(7.7, 8.8), (7.7, 7.7), (4.4, 7.7), (6.6, 7.7), (8.8, 7.7), and finally
(7.7, 7.7) again.
// *****************************
struct ltstr // less than
{
bool operator()(const float f1, const float f2) const
{
return f1 > f2;
}
};
int main(int argc, char* argv[])
{
set<float, ltstr > s;
s.insert(1.1);
s.insert(2.2);
s.insert(3.3);
s.insert(4.4);
s.insert(5.5);
s.insert(6.6);
s.insert(7.7);
s.insert(8.8);
s.insert(9.9);
s.erase(7.7);
....
JD
The last statement at the end of this post is to delete a set member
7.7. I set a break point inside ltstr:perator(). I found out that
STL binary-seach the set twice. How come? I have another problem that
a member in a set cannot be deleted. I think I may be able to solve
that problem if I can figure out the problem posted here. Thanks for
your help.
The sequence of (f1, f2) STL goes through is (7.7, 4.4), (7.7, 6.6),
(7.7, 8.8), (7.7, 7.7), (4.4, 7.7), (6.6, 7.7), (8.8, 7.7), and finally
(7.7, 7.7) again.
// *****************************
struct ltstr // less than
{
bool operator()(const float f1, const float f2) const
{
return f1 > f2;
}
};
int main(int argc, char* argv[])
{
set<float, ltstr > s;
s.insert(1.1);
s.insert(2.2);
s.insert(3.3);
s.insert(4.4);
s.insert(5.5);
s.insert(6.6);
s.insert(7.7);
s.insert(8.8);
s.insert(9.9);
s.erase(7.7);
....
JD