In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)06/01 Report--
The main contents of this paper are as follows:
1.vector
Definition of 1.1vector
Access to elements in the 1.2vector container
Common functions of 1.3vector
2.set
2.1 definition of set
Access to elements in the 2.2set container
Common functions of 2.3set
3.string
3.1 definition of string
Access to elements in the 3.2string container
Common functions of 3.3string
4.map
4.1 definition of map
4.2 access to elements in the map container
4.3 map common functions
5. Queue
5.1 definition of queue
5.2 access to elements in the queue container
5.3 queue common functions
5.4 queue Common uses
6.priority_queue
6.1 definition of priority_queue
6.2 access to elements in the priority_queue container
6.3 priority_queue common functions
6.4 setting the priority of elements in priority_queue
7. Stack
Definition of 7.1stack
Access to elements in the 7.2stack container
8. Pair
8.1 definition of pair
8.2 access to elements in pair
8.3 pair common functions
8.4 Common uses of pair
9. Algorithm header file
1.vector
Vector, array of variable length
Header file
# include
Definition of 1.1vector
Vector name
For example:
Vector name
If typename is vector
Vectorname
Equivalent to a two-dimensional array
Vector ArrayName [arraySize]
For example:
Vector vi [100]
Access to elements in the 1.2vector container
(1) access via subscript
Vi [index]
(2) access through iterator
Vector::iterator it
For example:
Vector::iterator it
When there is a context, you can directly use auto it=vi.begin ()
For example:
For (auto it=vi.begin (); itinervvi.end (); it++)
Printf ("% d", * it)
Note: vi.begin () and vi.end () close left and open right.
Common functions of 1.3vector
(1) push_back ()
Add an element at the end.
Vi.push_back (I)
(2) pop_back ()
Delete a tail element.
Vi.pop_back ()
(3) size ()
Returns the number of vector elements, note that it is of type unsigned.
Vi.size ()
(4) clear ()
Clear all elements in the vector.
Vi.clear ()
(5) insert ()
Insert (it,x) inserts an element x before the iterator it.
Vi: 1 2 3 4 5
Vi.insert (vi.begin () + 2)
Vi:1 2-1 3 4 5
(6) erase ()
1. Delete a single element
Vi:5 6 7 8 9
Vi.erase (vi.begin () + 3)
Vi:5 6 7 9
two。 Delete all elements in an interval
Erase [first,last); close left and open right
Vi:5 6 7 8 9
Vi.erase (vi.begin () + 1) vi.beginbread 4)
Vi:5 9
2.set
Collection, a container that is automatically ordered internally and does not contain repeating elements
Header file
# include
2.1 definition of set
Set name
For example:
Set name
Set array
SetArrayName [arraySize]
For example:
Set a [100]
Access to elements in the 2.2set container
Set can only be accessed with iterators
Set::iterator it
For example:
Set::iterator it
Set st
For (auto it=st.begin (); italization.end (); it++)
Print ("% d", * it)
St:2 3 5
Set elements are automatically sorted incrementally and repeating elements are automatically removed.
Note: it cannot be used
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.