#include <list>
#include <cassert>
#include <iostream>
static void listPart() {
using Group = std::list<float>;
Group a;
Group b = a;
Group c(a);
Group d(10);
Group e(10, 1.0f);
Group f(e.begin(), e.end());
Group g({1.0f, 2.0f, 3.0f});
Group h = {1.0f, 2.0f, 3.0f};
Group i {1.0f, 2.0f, 3.0f};
d.empty();
d.size();
d.max_size();
b = g;
b.assign(3, 1.0f);
b.assign(g.begin(), g.end());
b.assign({1.0f, 2.0f, 3.0f});
b.swap(a);
std::swap(a, b);
b.front();
b.back();
a.begin();
a.end();
a.cbegin();
a.cend();
a.rbegin();
a.rend();
a.crbegin();
a.crend();
a.resize(10);
auto iterBegin = a.begin();
assert(a.size() >= 10);
std::advance(iterBegin, 0);
for(; iterBegin != a.end(); ++iterBegin) std::cout << *iterBegin << " ";
a.pop_back();
if(!a.empty()) a.pop_back();
b.erase(b.begin());
b.erase(b.begin(), b.end());
b.push_back(10.0f);
b.pop_back();
b.push_front(1.2f);
b.emplace_front(1.3f);
auto iter = b.insert(b.end(), 100.0f);
iter = b.insert(b.end(), 10, -10.0f);
b.resize(5);
b.resize(10, 1.2f);
b.remove(1.0f);
b.remove_if([](auto v) { return v > 100.0f; });
b.reverse();
b.sort();
b.merge(g);
c.unique();
c.splice(c.begin(), b);
}
int main(void) {
listPart();
return 0;
}
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步