目录

set::end

描述 (Description)

它返回一个迭代器,引用set容器中的past-the-end元素。

声明 (Declaration)

以下是std :: set :: end在各种C ++版本中的工作方式。

C++98

iterator end();
const_iterator end() const;

C++11

 iterator end() noexcept;
const_iterator end() const noexcept;

返回值

它返回一个迭代器,引用set容器中的past-the-end元素。

异常 (Exceptions)

它从不抛出异常。

时间复杂

时间复杂性是不变的。

例子 (Example)

以下示例显示了std :: set :: end的用法。

#include <iostream>
#include <set>
int main () {
   int myints[] = {50,40,30,20,10};
   std::set<int> myset (myints,myints+10);
   std::cout << "myset contains:";
   for (std::set<int>::iterator it = myset.begin(); it!=myset.end(); ++it)
      std::cout << ' ' << *it;
   std::cout << '\n';
   return 0;
}

上述程序将正确编译和执行。

myset contains: -107717047 0 1 10 20 30 40 50 29015
↑回到顶部↑
WIKI教程 @2018