hash_set::end

注意事項注意事項

這個 API 已經過時。這個選項是 unordered_set Class

傳回處理成功最後一個項目位置 hash_set 的 Iterator。

const_iterator end( ) const; 
iterator end( );

傳回值

解決成功最後一個項目位置 hash_set 的雙向 Iterator。如果 hash_set 是 null,則 hash_set::end == hash_set::begin。

備註

end 用來測試 Iterator 是否已到達 hash_set 結尾。不應該取值 end 所傳回的值。

在 Visual C++ .NET Pocket PC, <hash_map><hash_set> 標頭檔 (Header File) 的成員不在 std 命名空間,,而是移至 stdext 命名空間。如需詳細資訊,請參閱 stdext 命名空間

範例

// hash_set_end.cpp
// compile with: /EHsc
#include <hash_set>
#include <iostream>

int main( )
{
   using namespace std;
   using namespace stdext;
   hash_set <int> hs1;
   hash_set <int> :: iterator hs1_Iter;
   hash_set <int> :: const_iterator hs1_cIter;
   
   hs1.insert( 1 );
   hs1.insert( 2 );
   hs1.insert( 3 );

   hs1_Iter = hs1.end( );
   hs1_Iter--;
   cout << "The last element of hs1 is " << *hs1_Iter << endl;

   hs1.erase( hs1_Iter );

   // The following 3 lines would err because the iterator is const:
   // hs1_cIter = hs1.end( );
   // hs1_cIter--;
   // hs1.erase( hs1_cIter );

   hs1_cIter = hs1.end( );
   hs1_cIter--;
   cout << "The last element of hs1 is now " << *hs1_cIter << endl;
}
  

需求

標題: <hash_set>

命名空間: stdext

請參閱

參考

hash_set Class

標準樣板程式庫