![]() |
---|
此 API 已过时。另一种方法是 unordered_multiset Class。 |
返回解决在 hash_multiset 的第一个元素的迭代器。
const_iterator begin( ) const;
iterator begin( );
返回值
解析一双向的迭代器在成功空 hash_multiset 的 hash_multiset 的第一个元素或位置。
备注
如果 begin 的返回值赋给 const_iterator,不能修改在 hash_multiset 对象的元素。如果 begin 的返回值赋给 迭代器,可以修改在 hash_multiset 对象的元素。
在 Visual C++ .NET 2003 中,<hash_map> 和 <hash_set> 标头文件的成员中不再标准,命名空间,而是将 stdext 命名空间。有关更多信息,请参见 stdext 命名空间。
示例
// hash_multiset_begin.cpp
// compile with: /EHsc
#include <hash_set>
#include <iostream>
int main( )
{
using namespace std;
using namespace stdext;
hash_multiset <int> hms1;
hash_multiset <int>::iterator hms1_Iter;
hash_multiset <int>::const_iterator hms1_cIter;
hms1.insert( 1 );
hms1.insert( 2 );
hms1.insert( 3 );
hms1_Iter = hms1.begin( );
cout << "The first element of hms1 is " << *hms1_Iter << endl;
hms1_Iter = hms1.begin( );
hms1.erase( hms1_Iter );
// The following 2 lines would err because the iterator is const
// hms1_cIter = hms1.begin( );
// hms1.erase( hms1_cIter );
hms1_cIter = hms1.begin( );
cout << "The first element of hms1 is now " << *hms1_cIter << endl;
}
要求
标头: <hash_set>
命名空间: stdext