文章分类 - STL
#include <bitset>
摘要:n 位 bitset 执行依次位运算的复杂度可视为 n / 32,效率较高。 位运算操作符 ~s, &, |, ^, >>, <<, ==, != [ ] 操作符 count :返回有多少位为 1。 any / none 若 s 所有位都为 0,则 s.any() 返回 false,s.none()
阅读全文
#include <map>
摘要:map 容器是一个键值对 key-value 的映射。是一颗以 key 为关键码的红黑树。 size / empty / clear / begin / end “ 双向访问迭代器 ”。对 map 的迭代器解除引用得到二元组 pair<key_type, value_type> insert / e
阅读全文
#include <set>
摘要:主要包括 set 和 multiset 两个容器,分别是 “ 有序集合 ” 和 “ 有序多重集 ”。 size / empty / clear, begin / end, insert, find, lower_bound / upper_bound, erase, count “双向访问迭代器”,
阅读全文
#include <deque>
摘要:随机访问, begin / end, front / back, push_back, push_front, pop_front, pop_back, clear
阅读全文
#include <queue>
摘要:主要包括循环队列 queue 和优先队列 priority_queue 两个容器。 queue push, pop, front, back priority_queue push, pop, top 重载 “ < ” 运算符 struct poi { int id; double x, y; };
阅读全文
#include <vector>
摘要:size / empty, clear, begin / end, front / back, push_back / pop_back 支持随机访问,不支持任意位置O(1)插入。 “随机访问迭代器” 所有的容器都可以视作“前闭后开”的结构。*a.end() 与 a[n] 都是越界访问。
阅读全文