deque::begin 和 deque::end

在 Visual C++ 演示如何使用 、向量、双端队列:: 启动、向量、双端队列:: 结束 标准 (STL)模板库函数。

const_iterator begin( ) const;
   iterator begin( );
const_iterator end( ) const;
   iterator end( );

备注

备注

类/参数名在原型不匹配版本在头文件。修改某些提高可读性。

启动 成员函数返回指向该序列中的第一个元素或在一个空序列之外的末尾的一个随机访问迭代器。 结束 成员函数返回序列之外的末尾点的一个随机访问迭代器。

示例

// begin.cpp
// compile with: /EHsc
//
// Functions:
//
//    begin()
//    end()

#include <iostream>
#include <deque>

using namespace std;

typedef deque<int >  INTDEQUE;

int main()
{

    // Create A and fill it with elements 1,2,3,4 and 5
    // using push_back function

    INTDEQUE  A;
    A.push_back(1);
    A.push_back(2);
    A.push_back(3);
    A.push_back(4);
    A.push_back(5);

    // Print the contents of A using iterator
    // and functions begin() and end()

     INTDEQUE::iterator pi;

    for(pi= A.begin();  pi !=A.end(); pi++)
    {
        cout << *pi <<" " ;
    }
        cout<<endl;
}

Output

1 2 3 4 5 

要求

**标题:**deque

请参见

概念

标准模板库示例