对set进行如下测试:
在set容器中依次插入8 7 6 5 4 3 2 1,set容器会对数据进行排序为 1 2 3 4 5 6 7 8, 但是在调试时发现显示的数据时而不正确,最后通过打印发现顺序其实是正确的。但是原因未知…
测试代码如下:
#include <termio.h>
#include <stdio.h>
#include <unistd.h>
#include <iostream>
#include <set>
int main(int argc, char *argv[]) {
std::set<int> test_set;
for (int i = 1; i < 9; ++i) {
test_set.insert( 9 - i);
}
std::set<int>::const_iterator it = test_set.begin();
for(; it!=test_set.end();++it) {
std::cout << *it;
}
}