命名空间
变体
操作

std::flat_set<Key,Compare,KeyContainer>::begin, std::flat_set<Key,Compare,KeyContainer>::cbegin

来自 cppreference.cn - C++ 参考手册
< C++‎ | 容器‎ | 平面集合
 
 
 
 
iterator begin() noexcept;
(1) (C++23 起)
const_iterator begin() const noexcept;
(2) (C++23 起)
const_iterator cbegin() const noexcept;
(3) (C++23 起)

返回一个指向 平面集合 首元素的迭代器。

如果 平面集合 为空,则返回的迭代器将等于 end()

range-begin-end.svg

目录

[编辑] 返回值

指向首元素的迭代器。

[编辑] 复杂度

常数。

注解

因为 iteratorconst_iterator 都是常量迭代器(并且实际上可能是相同的类型),所以无法通过这些成员函数返回的迭代器来修改容器的元素。

[编辑] 示例

#include <algorithm>
#include <flat_set>
#include <iostream>
 
int main()
{
    std::flat_set<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 2 3 4 5 6 9

[编辑] 参见

返回指向末尾的迭代器
(公共成员函数) [编辑]
(C++11)(C++14)
返回指向容器或数组开头的迭代器
(函数模板) [编辑]