vector, variable-length arrays, doubling the idea size () Returns the number of elements empty () returns is empty clear () Clear front()/back() push_back()/pop_back() begin()/end() [] Support comparison operations, according to the dictionary order pair<int, int> first, the first element second, the second element Support comparison operation to the first first key, a second key for the second order (lexicographically) String , String size () / length () Returns a string length empty() clear() substr (starting subscript, (substring length)) returns the substring the c_str () Returns a string starting address where the character array queue, the queue size() empty() push () to insert an element into the tail front () returns the head elements back () returns the tail element pop () pop the head elements priority_queue, priority queues, the default is large root heap push () to insert an element top () Returns the top of the stack elements pop () top of the stack pop element It is defined as the root of a small stack mode: The priority_queue < int , Vector < int >, Greater < int >> Q; stack, stack size() empty() push () insert element into a stack top () returns the top element pop () pop the top element No clear deque, deque size() empty() clear() Front () / Back () returns the first or last element push_back()/pop_back() push_front()/pop_front() begin()/end() [] SET , Map, multiset, the multimap, based on the balanced binary tree (red-black tree), dynamic maintenance ordered sequence size() empty() clear() the begin () / End () ++, - return predecessor and successor, the time complexity of O (logn) set/multiset insert () insert a number find () to find a number count () returns the number of a number of erase() ( 1 ) input is a number x, to remove all O X (K + logN) ( 2 ) Enter an iterator, delete this iterator lower_bound()/upper_bound() lower_bound (x) returns the minimum of x greater than or equal to the number of iterators upper_bound, (x) returns the minimum of x is greater than the number of iterators map/multimap insert () is inserted into a pair number Parameter erase () is the input pair or iterator find() [] Note multimap does not support this operation. Time complexity is O (logn) lower_bound()/upper_bound() unordered_set, unordered_map, unordered_multiset, unordered_multimap, 哈希表 And similar to the above, CRUD time complexity is O ( . 1 ) It does not support lower_bound () / upper_bound (), the iterator ++, - bitset, bit-pressure the bitset < 10000 > S; ~, &, |, ^ supports all operations >>, << ==, != [] Array may be used as count () returns the number of 1 any () determines whether there is at least a 1 none () determines whether all 0 SET () to all positions. 1 SET (k, v) becomes the k-th bit v reset () all the bits become 0 Flip () is equivalent to ~ negated Flip (k) the k-th bit inversion
vector
/ * The Vector, variable-length arrays, doubling the idea size () // returns the number of elements so that the container has empty () returns null // whether all containers have clear () Clear Queue not emptied front () / back () // returns the first or the last digit push_back()/pop_back() begin () / end () iterator [] Support comparison operations, according to the dictionary order */ #include<bits/stdc++.h> using namespace std ; int main() { // vector <int> A; // vector <int> A [10]; // Vector array, showing ten defined Vector // vector <int> A (10); // length of vector 10 of the vector < int > a ( 10 , . 3 ); // length of the vector 10, and each digital initialized. 3 for (Auto X: a) X COUT << << endl; } #include<bits/stdc++.h> using namespace std ; int main() { vector<int>a; for(int i=0;i<10;i++) a.push_back(i); for(int i=0;i<a.size();i++) cout<<a[i]<<" "; cout<<endl; for(vector<int>::iterator i=a.begin();i!=a.end();i++) cout<<*i<<" "; cout<<endl; for(auto i=a.begin();i!=a.end();i++) cout<<*i<<" "; COUT << endl; // iterator can be seen as a pointer, can be simplified * out for (Auto X: A) X COUT << << " " ; cout<<endl; } #include<bits/stdc++.h> using namespace std ; int main() { Vector < int > A ( . 4 , . 3 ), B ( . 3 , . 4 ); // lexicographic ordering IF (A <B) the puts ( " A <B " ); }
pair
/* pair<int, int> first, the first element second, the second element Support comparison operation to the first first key, a second key for the second order (lexicographically) */ #include<bits/stdc++.h> using namespace std ; int main() { pair<int,string>p; // pair<int,pair<int,int>>p 存储三个 p=make_pair(10,"ldy"); cout<<p.first<<endl<<p.second<<endl; return 0; }
string
/ * String, String size () / length () Returns a string length empty() clear() substr (starting subscript, (substring length)) returns the substring the c_str () Returns a string starting address where the character array */ #include<bits/stdc++.h> using namespace std ; int main() { string a="ldy"; a+="def"; a+='c'; cout<<a<<endl; COUT << a.substr ( . 1 , . 3 ) << endl; // substr (X, Y) the starting position, length COUT << a.substr ( . 1 , 10 ) << endl; // if the end is greater than the length, is output till the last COUT << a.substr ( 1 , 10 ) << endl; // output starting from the entire string of the printf ( " % S \ n- " , a.c_str ()); // with scanf output return 0 ; }
queue
/ * Queue, queue size() empty() push () to insert an element into the tail front () returns the head elements back () returns the tail element pop () pop the head elements No clear function */ #include<bits/stdc++.h> using namespace std ; int main() { queue<int>q; Q = Queue < int > (); // because it is not clear if the situation to be empty, can redefine return 0 ; }
priority_queue
/ * Priority_queue, priority queues, the default is large root heap push () to insert an element top () Returns the top of the stack elements pop () top of the stack pop element It is defined as the root of a small stack mode: priority_queue <int, vector <int>, greater <int >> q; */ #include<bits/stdc++.h> using namespace std ; int main() { priority_queue<int,vector<int>,greater<int>>heap;//小根堆 }
map
// like an array to use #include<bits/stdc++.h> using namespace std ; int main() { map<string,int>a; a["ldy"]=1; cout<<a["ldy"]<<endl; }