⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cs_hash.h

📁 c-smile 一个语法类似与JS 又有点像C++的 编译器
💻 H
字号:
/*
*
* cs_hash.h
*
* Copyright (c) 2001, 2002
* Andrew Fedoniouk - andrew@terra-informatica.org
* Portions: Serge Kuznetsov -  kuznetsov@deeptown.org
*
* See the file "COPYING" for information on usage 
* and redistribution of this file
*
*/
#ifndef __cs_hash_h
#define __cs_hash_h

#include "cs_string.h"

namespace tool
{
  template<>
  inline unsigned int
    hash<string> ( const string& the_string )
  {
    unsigned int h = 0, g;
    char *pc = const_cast<char *> ( (const char *) the_string );
    while ( *pc )
    {
      h = ( h << 4 ) + *pc++;
      if ( ( g = h & 0xF0000000 ) != 0 )
        h ^= g >> 24;
      h &= ~g;
    }
    return h;
  }

  typedef const char * const_char_ptr_t;

  template<>
  inline unsigned int
    hash<const_char_ptr_t> ( const const_char_ptr_t& p_string )
  {
    unsigned int h = 0, g;
    char *pc = const_cast<char *> ( p_string );

    while ( *pc )
    {
      h = ( h << 4 ) + *pc++;
      if ( ( g = h & 0xF0000000 ) != 0 )
        h ^= g >> 24;
      h &= ~g;
    }
    return h;
  }


  template<>
  inline unsigned int
    hash<long> ( const long& the_long )
  {
    return (unsigned int) the_long;
  }


  template<>
  inline unsigned int
    hash<int> ( const int& the_int )
  {
    return (unsigned int) the_int;
  }


  template<>
  inline unsigned int
    hash<word> ( const word& the_word )
  {
    return (unsigned int) the_word;
  }

  template<>
  inline unsigned int
    hash<dword> ( const dword& the_dword )
  {
    return (unsigned int) the_dword;
  }

};

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -