#include <list>
#include <vector>
#include <algorithm>
using std::list;
using std::vector;
using std::lower_bound;
//
template <typename conainer>
void print(const conainer &t)
{
for (typename conainer::const_iterator it=t.begin(); it!=t.end(); ++it) {
printf("%d ", *it);
}
printf("\n");
}
//
int main()
{
int value = 0;
list<int> tlist;
list<int>::iterator it;
// vector<int> tlist;
// vector<int>::iterator it;
value = 5; printf("%d -> ", value); it = lower_bound(tlist.begin(), tlist.end(), value); tlist.insert(it, value); print(tlist);
value = 2; printf("%d -> ", value); it = lower_bound(tlist.begin(), tlist.end(), value); tlist.insert(it, value); print(tlist);
value = 1; printf("%d -> ", value); it = lower_bound(tlist.begin(), tlist.end(), value); tlist.insert(it, value); print(tlist);
value = 8; printf("%d -> ", value); it = lower_bound(tlist.begin(), tlist.end(), value); tlist.insert(it, value); print(tlist);
value = 9; printf("%d -> ", value); it = lower_bound(tlist.begin(), tlist.end(), value); tlist.insert(it, value); print(tlist);
value = 3; printf("%d -> ", value); it = lower_bound(tlist.begin(), tlist.end(), value); tlist.insert(it, value); print(tlist);
value = 0; printf("%d -> ", value); it = lower_bound(tlist.begin(), tlist.end(), value); tlist.insert(it, value); print(tlist);
value = 6; printf("%d -> ", value); it = lower_bound(tlist.begin(), tlist.end(), value); tlist.insert(it, value); print(tlist);
value = 7; printf("%d -> ", value); it = lower_bound(tlist.begin(), tlist.end(), value); tlist.insert(it, value); print(tlist);
value = 4; printf("%d -> ", value); it = lower_bound(tlist.begin(), tlist.end(), value); tlist.insert(it, value); print(tlist);
return 0;
};
排序向量
最新推荐文章于 2021-07-20 23:48:46 发布