deque::begin 和 deque::end
說明如何使用 deque::begin 和 deque::end Visual C++ 標準樣板程式庫 (STL) 函式。
const_iterator begin( ) const;
iterator begin( );
const_iterator end( ) const;
iterator end( );
備註
![]() |
---|
在原型中的類別/參數名稱不相符的標頭檔中的版本。某些已修改以提高可讀性。 |
開始成員函式會傳回隨機存取 iterator 該點在第一個元素的順序,或只是超出空序列結尾。 結束成員函式會傳回隨機存取 iterator 那些只是超出序列結尾的點。
範例
// 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>