iterator begin(); | ||
const_iterator begin() const; | ||
const_iterator cbegin() const; | (since C++11) |
Returns an iterator to the first element of the container.
If the container is empty, the returned iterator will be equal to end()
.
(none).
Iterator to the first element.
(none) | (until C++11) |
noexcept specification: noexcept | (since C++11) |
Constant.
#include <iostream> #include <map> int main() { std::map<int, float> num_map; num_map[4] = 4.13; num_map[9] = 9.24; num_map[1] = 1.09; for (auto it = num_map.begin(); it != num_map.end(); ++it) { // calls a_map.begin() and a_map.end() std::cout << it->first << ", " << it->second << '\n'; } }
Output:
1, 1.09 4, 4.13 9, 9.24
returns an iterator to the end (public member function) |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
http://en.cppreference.com/w/cpp/container/map/begin