Skip to content

不解决冲突的hashtable,在做hashcode时候存在负数bug #1

@Zhucola

Description

@Zhucola

hashTable\HashTable.php文件,hashFunc方法,会生成一个负数,在SplFixedArray数组中没有负数范围
建议改为如下:

private function hashFunc($key){
            $sum = crc32($key);
            $index = $sum % $this->size;
            if($index<0){
                return $index + $this->size;
            }
            return $index;
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions