collate::hash
根據其 Facet 特定規則來判斷序列的雜湊值。
long hash(
const CharType* _First,
const CharType* _Last
) const;
參數
_First
的序列要判斷第一個字元的指標在具有的值。_Last
的序列要判斷到最後一個字元的指標在具有的值。
傳回值
型別 long 的雜湊值的序列。
備註
成員函式傳回 do_hash(_First, _Last)。
雜湊值會很有用,例如,在分散式序列提供選擇性跨清單的陣列。
範例
// 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;
}
需求
標題: <locale>
命名空間: std