Partager via


hash_map::crend

Returns a const iterator that addresses the location succeeding the last element in a reversed hash_map.

const_reverse_iterator crend( ) const; 

Return Value

A const reverse bidirectional iterator that addresses the location succeeding the last element in a reversed hash_map Class (the location that had preceded the first element in the unreversed hash_map).

Remarks

crend is used with a reversed hash_map just as hash_map::end is used with a hash_map.

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

crend can be used to test to whether a reverse iterator has reached the end of its hash_map.

The value returned by crend should not be dereferenced.

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_crend.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_reverse_iterator hm1_crIter;
   typedef pair <int, int> Int_Pair;

   hm1.insert ( Int_Pair ( 3, 30 ) );

   hm1_crIter = hm1.crend( );
   hm1_crIter--;
   cout << "The last element of the reversed hash_map hm1 is "
        << hm1_crIter -> first << "." << endl;
}
The last element of the reversed hash_map hm1 is 3.

Requirements

Header: <hash_map>

Namespace: stdext

See Also

Reference

hash_map Class

Standard Template Library

Other Resources

hash_map Members