【笔记】 STL容器
vector
vector<int> v;
v.push_back(x);
v.emplace(x);
v.size();
v.erase(v.begin(),v.begin()+pos);
v.insert(v.begin()+pos,x);
lower_bound(v.begin(),v.end())-v.begin();
v.clear();
bitset
bitset<8> s ("00011011");
cout << s.count() << endl; //5 (求bitset中1的个数
cout << s.size() << endl; //8 (求bitset的大小
cout << s.test(0) << endl; //true (查下标处的元素是0还是1,并返回false或true,此处s[0]为1(最右),返回true
cout << s.any() << endl; //true (是否有1
cout << s.none() << endl; //false (是否无1
cout << s.all() << endl; //false (是否全部为1
mp.find(key)!=mp.end();//map的find查找的是键值
s.find(val)!=s.end();//set的find就是查元素在不在集合里
stack
stack<int> stk;
stk.push(x);
stk.pop();
stk.top();
stk.size();
stk.empty();
queue
queue<int> q;
q.push(x);
q.pop()
q.front();
q.back();
q.size();
deque
deque<int> dq;
dq.push_back(x);
dq.push_front(x);
dq.front();
dq.back();
dq.pop_front();
dq.pop_back();
dq.size();
priority_queue
//大根堆
priority_queue<int,vector<int>,less<int> >pq;//简写:priority_queue<int> pq;
/*小根堆
priority_queue<int,vector<int>,greater<int>> pq//无简写
*/
pq.push(x);
pq.emplace(x);
pq.size();
pq.empty();
pq.top();
pq.pop();
heap(?)
makeheap(a+1,a+n+1);
pushheap(a+1,a+n+1);
popheap(a+1,a+n+1);
(multi/unordered_)map
map<int,int> mp;
mp[x]=y;
mp.lower_bound(x);
mp.emplace(x,y);
mp.insert(make_pair(x,y));
for(auto v:mp) v.first++;
mp.size();
mp.empty();
mp.clear();
(multi/unordered_)set
set<int> s;
s.emplace(x);
s.insert(x);
s.erase(x);
s.lower_bound(x);
s.size();
s.empty();
s.clear();