From b3956c9e88a7611705c57cee913dadd727e0cd66 Mon Sep 17 00:00:00 2001 From: krahets Date: Wed, 4 Oct 2023 02:44:58 +0800 Subject: [PATCH] build --- chapter_hashing/hash_algorithm.md | 1 + chapter_hashing/hash_collision.md | 10 +++++----- chapter_hashing/hash_map.md | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/chapter_hashing/hash_algorithm.md b/chapter_hashing/hash_algorithm.md index 4262878ba..927ae76f3 100644 --- a/chapter_hashing/hash_algorithm.md +++ b/chapter_hashing/hash_algorithm.md @@ -37,6 +37,7 @@ index = hash(key) % capacity 对于密码学的相关应用,为了防止从哈希值推导出原始密码等逆向工程,哈希算法需要具备更高等级的安全特性。 +- **单向性**:无法通过哈希值反推出关于输入数据的任何信息。 - **抗碰撞性**:应当极其困难找到两个不同的输入,使得它们的哈希值相同。 - **雪崩效应**:输入的微小变化应当导致输出的显著且不可预测的变化。 diff --git a/chapter_hashing/hash_collision.md b/chapter_hashing/hash_collision.md index 68cc3566b..a375d0284 100644 --- a/chapter_hashing/hash_collision.md +++ b/chapter_hashing/hash_collision.md @@ -59,7 +59,7 @@ comments: true """负载因子""" return self.size / self.capacity - def get(self, key: int) -> str: + def get(self, key: int) -> str | None: """查询操作""" index = self.hash_func(key) bucket = self.buckets[index] @@ -167,8 +167,8 @@ comments: true return pair->val; } } - // 若未找到 key 则返回 nullptr - return nullptr; + // 若未找到 key 则返回空字符串 + return ""; } /* 添加操作 */ @@ -386,7 +386,7 @@ comments: true } /* 查询操作 */ - public string get(int key) { + public string? get(int key) { int index = hashFunc(key); // 遍历桶,若找到 key 则返回对应 val foreach (Pair pair in buckets[index]) { @@ -1792,7 +1792,7 @@ comments: true } /* 查询操作 */ - public string get(int key) { + public string? get(int key) { // 搜索 key 对应的桶索引 int index = findBucket(key); // 若找到键值对,则返回对应 val diff --git a/chapter_hashing/hash_map.md b/chapter_hashing/hash_map.md index 362c64211..8e09e6724 100755 --- a/chapter_hashing/hash_map.md +++ b/chapter_hashing/hash_map.md @@ -621,7 +621,7 @@ index = hash(key) % capacity int index = hashFunc(key); Pair *pair = buckets[index]; if (pair == nullptr) - return nullptr; + return ""; return pair->val; }