HashKey
TRY
TOC
Collapse the table of content
Expand the table of content
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

HashKey

Calculates a hash value for the given key.

template<class ARG_KEY>
AFX_INLINE UINT AFXAPI HashKey(
   ARG_KEY key 
);

Parameters

ARG_KEY
Template parameter specifying the data type used to access map keys.
key
The key whose hash value is to be calculated.

Return Value

The key's hash value.

Remarks

This function is called directly by CMap::RemoveKey and indirectly by CMap::Lookup and CMap::Operator [].

The default implementation creates a hash value by shifting key right by four positions. Override this function so that it returns hash values appropriate for your application.

Example

template <> UINT AXPAPI HashKey( unsigned __int64 key )
{
   // Generate the hash value by XORing the lower 32 bits of the number 
   // with the upper 32 bits
   return( UINT( key )^UINT( key>>32 ) );
}

See Also

MFC Macros and Globals | CMap

Show:
© 2016 Microsoft