std::flat_multiset<Key,Compare,KeyContainer>::begin, std::flat_multiset<Key,Compare,KeyContainer>::cbegin
来自cppreference.com
<tbody>
</tbody>
iterator begin() noexcept; |
(1) | (C++23 起) |
const_iterator begin() const noexcept; |
(2) | (C++23 起) |
const_iterator cbegin() const noexcept; |
(3) | (C++23 起) |
返回指向 flat_multiset 首元素的迭代器。
如果 flat_multiset 为空,那么返回的迭代器等于 end()。
返回值
指向首元素的迭代器。
复杂度
常数。
注解
因为 iterator 和 const_iterator 都是常迭代器(而且实际上可以是同一类型),故不可能通过任何这些成员函数返回的迭代器修改容器元素。
示例
运行此代码
#include <algorithm>
#include <flat_set>
#include <iostream>
int main()
{
std::flat_multiset<int> set{3, 1, 4, 1, 5, 9, 2, 6, 5};
std::for_each(set.cbegin(), set.cend(), [](int x)
{
std::cout << x << ' ';
});
std::cout << '\n';
}
输出:
1 1 2 3 4 5 5 6 9
参阅
| 返回指向末尾的迭代器 (公开成员函数) | |
(C++11)(C++14) |
返回指向容器或数组起始的迭代器 (函数模板) |