Skip to content

Commit

Permalink
Merge pull request #36 from StoneHao/patch-1
Browse files Browse the repository at this point in the history
最后都按位与了一个1,就是为了保证生成出来的随机数都是奇数。
  • Loading branch information
halfrost authored Dec 28, 2023
2 parents bd6ebe8 + 6677126 commit c1ef978
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions contents/Go/go_map_chapter_one.md
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ func alginit() {

```

在这个初始化的函数中,初始化了2个数组,数组里面装的都是随机的 hashkey。在 386、 amd64、非 nacl 的平台上,会用 aeshash 。这里会把随机的 key 生成好,存入到 aeskeysched 数组中。同理,hashkey 数组里面也会随机好4个数字。最后都按位与了一个1,就是为了保证生成出来的随机数都是奇数。
在这个初始化的函数中,初始化了2个数组,数组里面装的都是随机的 hashkey。在 386、 amd64、非 nacl 的平台上,会用 aeshash 。这里会把随机的 key 生成好,存入到 aeskeysched 数组中。同理,hashkey 数组里面也会随机好4个数字。最后都按位或了一个1,就是为了保证生成出来的随机数都是奇数。

接下来举个例子,来看看 memhash 究竟是如何计算哈希值的。

Expand Down Expand Up @@ -2207,4 +2207,4 @@ Reference:
>
> Follow: [halfrost · GitHub](https://github.com/halfrost)
>
> Source: [https://halfrost.com/go\_map/](https://halfrost.com/go_map/)
> Source: [https://halfrost.com/go\_map/](https://halfrost.com/go_map/)

0 comments on commit c1ef978

Please sign in to comment.