Here is the vector of all the construction method, the member method of some summary, specific can look at the following links.
Original address: http://www.cplusplus.com/reference/vector/vector/operator[]/Public member function<vector> std::vector::operator[]
Reference operator[] (size_type n); Const_reference operator[] (size_type n) const;
Returns a reference to the element that points to position N.
A similar approach is at, with the same behavior as the method, where at is the bounds of the detection, and the Out_of_range exception is thrown when the requested position is out of range.
This method should not be called when N is out of range, which results in an unknown error.
Parameters
- N
n is the position of the element in the container.
Note the position of the first element is 0 instead of 1.
Return ValueThe return value is a reference to the element at the specified location.
If the size of the container is greater than N, no exception is thrown.
Otherwise, an unknown error is caused.
Original address: http://blog.csdn.net/qq844352155/article/details/38685515
———————————————————————————————————————————————————
Public member function<vector> std::vector::at
Reference at (size_type N), const_reference at (size_type N) const;
Returns a reference to the element that points to position N.
The method will automatically detect if n is in a valid range, and if not, the Out_of_range exception will be thrown.
Another control method is operator[], and this method does not detect the validity of the data.
Parameters
- N
n is the position of the element in the vector.
If n is greater than or equal to the size of the array, the Out_of_range exception is thrown.
Notice that the first element has a position of 0 instead of 1.
Return Value
The return value is the value of the element at the specified position within the container
Throws an Out_of_range exception when n is not in range.
Original address: http://blog.csdn.net/qq844352155/article/details/38599145
_______________________________________________________________________________________________________________ ___________________________
Public member function<vector> std::vector::front
Reference front (); const_reference Front () const;
Accessing the first element
Returns a reference to the first element.
Unlike begin, begin is to return an iterator, and front is to return a direct reference.
calling this method on an empty container will cause Unexpected results .
ParametersNone
Return Value
A reference to the first element in the vector container.
Original address: http://blog.csdn.net/qq844352155/article/details/38458047
———————————————————————————————————————————————————
Public member function<vector> std::vector::back
Reference back (); const_reference back () const;
Returns a reference to the last element.
Unlike end, end is an iterator that returns a pointer to an extra-tailed element, which returns a reference directly.
Calling this method on an empty container results in an unknown behavior.
ParametersNone
Return ValueThe return value is a reference to the last element in the vector.
Original address: http://blog.csdn.net/qq844352155/article/details/38516647
—————————————————————————————————————————————————————————————————————————————
Public member function<vector> std::vector::d ata
value_type* data () noexcept;const value_type* data () const noexcept;
returns a pointer to the location of the vector element stored directly in memory.
Because the elements inside the vector are stored sequentially, the pointer can access all the elements in the array by an offset.
Parameters
None
Return Value
Returns a pointer to the memory where the first element of the array resides.
——————————————————————————————————————————————————————————————————
Summary of the bad place please a lot of guidance, you can leave a message or click on the top left email address to send me an e-mail, point out my errors and shortcomings, so that I modify, better share to everyone, thank you.
Reprint Please specify source: http://blog.csdn.net/qq844352155
Author: unparalleled
Email:[email protected]
2014-8-27
From Gdut
——————————————————————————————————————————————————————————————————
STL Vector Summary (iv) Element access (PNS)