Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Determines the hash value of sequence according to their facet-specific rules.
long hash(
const CharType* _First,
const CharType* _Last
) const;
Parameters
_First
A pointer to the first character in the sequence whose has value is to be determined._Last
A pointer to the last character in the sequence whose has value is to be determined.
Return Value
A hash value of type long for the sequence.
Remarks
The member function returns do_hash(_First, _Last).
A hash value can be useful, for example, in distributing sequences pseudo-randomly across an array of lists.
Example
// collate_hash.cpp
// compile with: /EHsc
#include <locale>
#include <iostream>
#include <tchar.h>
using namespace std;
int main( )
{
locale loc ( "German_germany" );
_TCHAR * s1 = _T("\x00dfzz abc."); // \x00df is the German sharp-s (looks like beta), it comes before z in the alphabet
_TCHAR * s2 = _T("zzz abc."); // \x00df is the German sharp-s (looks like beta), it comes before z in the alphabet
long r1 = use_facet< collate<_TCHAR> > ( loc ).
hash (s1, &s1[_tcslen( s1 )-1 ]);
long r2 = use_facet< collate<_TCHAR> > ( loc ).
hash (s2, &s2[_tcslen( s2 )-1 ] );
cout << r1 << " " << r2 << endl;
}
541187293 551279837
Requirements
Header: <locale>
Namespace: std