map.cpp

来自「Shorthand是一个强大的脚本语言」· C++ 代码 · 共 28 行

CPP
28
字号
///////////////////////////////////////////////////////////////////////////////
// $Header: /shorthand/src/map.cpp 2     8/28/02 6:27a Arm $
//-----------------------------------------------------------------------------
// Project: ShortHand interpreter
// Author: Andrei Remenchuk <andrei@remenchuk.com>
//-----------------------------------------------------------------------------
// map.cpp: simple hash map
///////////////////////////////////////////////////////////////////////////////
#include "map.h"


/**
 * Java-style hash function.
 */
int hashCode(const char* s)
{
    if (s == NULL || *s == '\0') return 0;
    int n = strlen(s)-1;
    int i = 0;
    int hash = 0;
    while(s[i]) {
        hash += s[i]*(31^(n-1));
        n--;
        i++;
    }
    return hash;
}

⌨️ 快捷键说明

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