Skip to content

Commit

Permalink
Update index.md
Browse files Browse the repository at this point in the history
Add the code to hash_algorithm.md
  • Loading branch information
krahets committed Jul 3, 2023
1 parent bf1bccc commit 200275b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
22 changes: 22 additions & 0 deletions docs/chapter_hashing/hash_algorithm.md
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,29 @@ $$
=== "Swift"

```swift title="built_in_hash.swift"
let num = 3
let hashNum = num.hashValue
// 整数 3 的哈希值为 9047044699613009734

let bol = true
let hashBol = bol.hashValue
// 布尔量 true 的哈希值为 -4431640247352757451

let dec = 3.14159
let hashDec = dec.hashValue
// 小数 3.14159 的哈希值为 -2465384235396674631

let str = "Hello 算法"
let hashStr = str.hashValue
// 字符串 Hello 算法 的哈希值为 -7850626797806988787

let arr = [AnyHashable(12836), AnyHashable("小哈")]
let hashTup = arr.hashValue
// 数组 [AnyHashable(12836), AnyHashable("小哈")] 的哈希值为 -2308633508154532996

let obj = ListNode(x: 0)
let hashObj = obj.hashValue
// 节点对象 utils.ListNode 的哈希值为 -2434780518035996159
```

=== "Zig"
Expand Down
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ hide:
<tbody>
<td align="center"><a href="https://github.com/Gonglja"><img src="https://avatars.githubusercontent.com/u/39959756?v=4" width="50px;" alt="Gonglja"/><br /><sub><b>Gonglja</b></sub></a><br /><sub>C / C++</sub></td>
<td align="center"><a href="https://github.com/gvenusleo"><img src="https://avatars.githubusercontent.com/u/79075347?v=4" width="50px;" alt="gvenusleo"/><br /><sub><b>gvenusleo</b></sub></a><br /><sub>Dart</sub></td>
<td align="center"><a href="https://github.com/hpstory"><img src="https://avatars.githubusercontent.com/u/33348162?v=4" width="50px;" alt="hpstory"/><br /><sub><b>hpstory</b></sub></a><br /><sub>C#</sub></td>
<td align="center"><a href="https://github.com/justin-tse"><img src="https://avatars.githubusercontent.com/u/24556310?v=4" width="50px;" alt="justin-tse"/><br /><sub><b>justin-tse</b></sub></a><br /><sub>JS / TS</sub></td>
<td align="center"><a href="https://github.com/krahets"><img src="https://avatars.githubusercontent.com/u/26993056?v=4" width="50px;" alt="krahets"/><br /><sub><b>krahets</b></sub></a><br /><sub>Java / Python</sub></td>
<td align="center"><a href="https://github.com/nuomi1"><img src="https://avatars.githubusercontent.com/u/3739017?v=4" width="50px;" alt="nuomi1"/><br /><sub><b>nuomi1</b></sub></a><br /><sub>Swift</sub></td>
Expand Down

0 comments on commit 200275b

Please sign in to comment.