collate::hash

基于其方面特定规则确定序列的哈希值。

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

请参见

参考

collate Class