共用方式為


hash_map::cbegin

Returns a const iterator addressing the first element in the hash_map.

const_iterator cbegin( ) const;

Return Value

A const bidirectional iterator addressing the first element in the hash_map Class or the location succeeding an empty hash_map.

Remark

With the return value of cbegin, the hash_map object cannot be modified.

In Visual C++ .NET 2003, members of the <hash_map> and <hash_set> header files are no longer in the std namespace, but rather have been moved into the stdext namespace. See The stdext Namespace for more information.

Example

// hash_map_cbegin.cpp
// compile with: /EHsc
#define _DEFINE_DEPRECATED_HASH_CLASSES 0
#include <hash_map>
#include <iostream>

int main( )
{
   using namespace std;
   using namespace stdext;
   hash_map <int, int> hm1;

   hash_map <int, int> :: const_iterator hm1_cIter;
   typedef pair <int, int> Int_Pair;

   hm1.insert ( Int_Pair ( 2, 4 ) );

   hm1_cIter = hm1.cbegin ( );
   cout << "The first element of hm1 is " 
        << hm1_cIter -> first << "." << endl;
   }
The first element of hm1 is 2.

Requirements

Header: <hash_map>

Namespace: stdext

See Also

Reference

hash_map Class

Standard Template Library

Other Resources

hash_map Members