From 200275b39a90270e54fc0a5ce8d794767a79c2df Mon Sep 17 00:00:00 2001 From: krahets Date: Mon, 3 Jul 2023 16:56:42 +0800 Subject: [PATCH] Update index.md Add the code to hash_algorithm.md --- docs/chapter_hashing/hash_algorithm.md | 22 ++++++++++++++++++++++ docs/index.md | 1 + 2 files changed, 23 insertions(+) diff --git a/docs/chapter_hashing/hash_algorithm.md b/docs/chapter_hashing/hash_algorithm.md index f48513f40..0273e99d2 100644 --- a/docs/chapter_hashing/hash_algorithm.md +++ b/docs/chapter_hashing/hash_algorithm.md @@ -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" diff --git a/docs/index.md b/docs/index.md index 9d2e99f57..aef9799c6 100644 --- a/docs/index.md +++ b/docs/index.md @@ -113,6 +113,7 @@ hide: Gonglja
Gonglja

C / C++ gvenusleo
gvenusleo

Dart + hpstory
hpstory

C# justin-tse
justin-tse

JS / TS krahets
krahets

Java / Python nuomi1
nuomi1

Swift