共用方式為


unordered_set::begin

指定受控制序列或 Bucket 的開頭。

iterator begin();
const_iterator begin() const;
local_iterator begin(size_type nbucket);
const_local_iterator begin(size_type nbucket) const;

參數

參數

描述

nbucket

Bucket 數目。

備註

前兩個成員函式傳回轉送點序列中的第一個項目的 Iterator (或在空序列的結尾)。 最後兩個成員函式傳回轉送會在 nbucket Bucket 的第一個項目的 Iterator (或在空的 Bucket 末端)。

範例

// unordered_set_begin.cpp 
// compile using: cl.exe /EHsc /nologo /W4 /MTd 
#include <unordered_set> 
#include <iostream> 

using namespace std;

typedef unordered_set<char> MySet;

int main() 
{ 
    MySet c1; 

    c1.insert('a'); 
    c1.insert('b'); 
    c1.insert('c'); 

    // display contents using range-based for 
    for (auto it : c1) {
        cout << " [" << it << "]"; 
    }

    cout << endl; 

    // display contents using explicit for
    for (MySet::const_iterator it = c1.begin(); it != c1.end(); ++it) {
        cout << " [" << *it << "]"; 
    }

    cout << std::endl; 

    // display first two items
    MySet::iterator it2 = c1.begin(); 
    cout << " [" << *it2 << "]"; 
    ++it2; 
    cout << " [" << *it2 << "]"; 
    cout << endl; 

    // display bucket containing 'a' 
    MySet::const_local_iterator lit = c1.begin(c1.bucket('a')); 
    cout << " [" << *lit << "]"; 

    return (0); 
} 
  
  
  
  

需求

標題: <unordered_set>

命名空間: std

請參閱

參考

<unordered_set>

unordered_set Class

unordered_set::end

其他資源

<unordered_set> 成員