From 6d19673be3c1a2cdfcf2a9c1519d870621349895 Mon Sep 17 00:00:00 2001 From: Yudong Jin Date: Mon, 23 Nov 2026 21:50:05 +0800 Subject: [PATCH] Fix demo comments and labels that contradict the code (#2048) Fix Chinese wording that contradicted the demo code: the C++ std::hash scope, the Rust node-value hash label, the Go Pop comment and the Go stack test comment. Russian sources and all six editions' snippets follow; the Go heap snippets drop the repository-only PrintHeap call. Co-Authored-By: Claude Opus 5.5 --- codes/cpp/chapter_hashing/built_in_hash.cpp | 2 +- codes/go/chapter_heap/heap.go | 2 +- codes/go/chapter_heap/top_k.go | 2 +- codes/go/chapter_stack_and_queue/stack_test.go | 2 +- codes/rust/chapter_hashing/build_in_hash.rs | 2 +- codes/snippets/chapter_hashing/hash_algorithm.md | 6 +++--- codes/snippets/chapter_heap/heap.md | 3 +-- en/codes/cpp/chapter_hashing/built_in_hash.cpp | 2 +- en/codes/go/chapter_heap/heap.go | 2 +- en/codes/go/chapter_heap/top_k.go | 2 +- en/codes/go/chapter_stack_and_queue/stack_test.go | 2 +- en/codes/rust/chapter_hashing/build_in_hash.rs | 2 +- .../snippets/chapter_hashing/hash_algorithm.md | 6 +++--- en/codes/snippets/chapter_heap/heap.md | 3 +-- ja/codes/cpp/chapter_hashing/built_in_hash.cpp | 2 +- ja/codes/go/chapter_heap/heap.go | 2 +- ja/codes/go/chapter_heap/top_k.go | 2 +- ja/codes/go/chapter_stack_and_queue/stack_test.go | 2 +- ja/codes/rust/chapter_hashing/build_in_hash.rs | 2 +- .../snippets/chapter_hashing/hash_algorithm.md | 6 +++--- ja/codes/snippets/chapter_heap/heap.md | 3 +-- ko/codes/cpp/chapter_hashing/built_in_hash.cpp | 2 +- ko/codes/go/chapter_heap/heap.go | 2 +- ko/codes/go/chapter_heap/top_k.go | 2 +- ko/codes/go/chapter_stack_and_queue/stack_test.go | 2 +- ko/codes/rust/chapter_hashing/build_in_hash.rs | 2 +- .../snippets/chapter_hashing/hash_algorithm.md | 6 +++--- ko/codes/snippets/chapter_heap/heap.md | 3 +-- ru/codes/cpp/chapter_hashing/built_in_hash.cpp | 2 +- ru/codes/go/chapter_heap/heap.go | 2 +- ru/codes/go/chapter_heap/top_k.go | 2 +- ru/codes/go/chapter_stack_and_queue/stack_test.go | 2 +- ru/codes/rust/chapter_hashing/build_in_hash.rs | 2 +- .../snippets/chapter_hashing/hash_algorithm.md | 6 +++--- ru/codes/snippets/chapter_heap/heap.md | 3 +-- .../codes/cpp/chapter_hashing/built_in_hash.cpp | 2 +- zh-hant/codes/go/chapter_heap/heap.go | 2 +- zh-hant/codes/go/chapter_heap/top_k.go | 2 +- .../codes/go/chapter_stack_and_queue/stack_test.go | 2 +- .../codes/rust/chapter_hashing/build_in_hash.rs | 2 +- .../snippets/chapter_hashing/hash_algorithm.md | 14 +++++++------- zh-hant/codes/snippets/chapter_heap/heap.md | 3 +-- 42 files changed, 58 insertions(+), 64 deletions(-) diff --git a/codes/cpp/chapter_hashing/built_in_hash.cpp b/codes/cpp/chapter_hashing/built_in_hash.cpp index 1c06c77e61..efabfbdf5c 100644 --- a/codes/cpp/chapter_hashing/built_in_hash.cpp +++ b/codes/cpp/chapter_hashing/built_in_hash.cpp @@ -24,6 +24,6 @@ int main() { size_t hashStr = hash()(str); cout << "字符串 " << str << " 的哈希值为 " << hashStr << "\n"; - // 在 C++ 中,内置 std::hash() 仅提供基本数据类型的哈希值计算 + // 在 C++ 中,内置 std::hash() 仅提供基本数据类型和部分标准库类型(如 std::string)的哈希值计算 // 数组、对象的哈希值计算需要自行实现 } diff --git a/codes/go/chapter_heap/heap.go b/codes/go/chapter_heap/heap.go index 56a67f5cc4..5f46b96764 100644 --- a/codes/go/chapter_heap/heap.go +++ b/codes/go/chapter_heap/heap.go @@ -15,7 +15,7 @@ func (h *intHeap) Push(x any) { *h = append(*h, x.(int)) } -// Pop heap.Interface 的函数,实现弹出堆顶元素 +// Pop heap.Interface 的函数,弹出切片末尾元素(heap.Pop 已将堆顶元素交换至末尾) func (h *intHeap) Pop() any { // 待出堆元素存放在最后 last := (*h)[len(*h)-1] diff --git a/codes/go/chapter_heap/top_k.go b/codes/go/chapter_heap/top_k.go index 4874c3fb15..39d793a888 100644 --- a/codes/go/chapter_heap/top_k.go +++ b/codes/go/chapter_heap/top_k.go @@ -17,7 +17,7 @@ func (h *minHeap) Push(x any) { *h = append(*h, x.(int)) } -// Pop heap.Interface 的方法,实现弹出堆顶元素 +// Pop heap.Interface 的方法,弹出切片末尾元素(heap.Pop 已将堆顶元素交换至末尾) func (h *minHeap) Pop() any { // 待出堆元素存放在最后 last := (*h)[len(*h)-1] diff --git a/codes/go/chapter_stack_and_queue/stack_test.go b/codes/go/chapter_stack_and_queue/stack_test.go index d881c5ec8f..61e380ff4c 100644 --- a/codes/go/chapter_stack_and_queue/stack_test.go +++ b/codes/go/chapter_stack_and_queue/stack_test.go @@ -45,7 +45,7 @@ func TestStack(t *testing.T) { } func TestArrayStack(t *testing.T) { - // 初始化栈, 使用接口承接 + // 初始化栈 stack := newArrayStack() // 元素入栈 diff --git a/codes/rust/chapter_hashing/build_in_hash.rs b/codes/rust/chapter_hashing/build_in_hash.rs index 09a128f2de..7ecf0138ae 100644 --- a/codes/rust/chapter_hashing/build_in_hash.rs +++ b/codes/rust/chapter_hashing/build_in_hash.rs @@ -45,5 +45,5 @@ fn main() { let mut hasher = DefaultHasher::new(); node.borrow().val.hash(&mut hasher); let hash = hasher.finish(); - println!("节点对象 {:?} 的哈希值为 {}", node, hash); + println!("节点 {:?} 中节点值的哈希值为 {}", node, hash); } diff --git a/codes/snippets/chapter_hashing/hash_algorithm.md b/codes/snippets/chapter_hashing/hash_algorithm.md index 87ce9d5e20..70d421b163 100644 --- a/codes/snippets/chapter_hashing/hash_algorithm.md +++ b/codes/snippets/chapter_hashing/hash_algorithm.md @@ -52,7 +52,7 @@ size_t hashStr = hash()(str); cout << "字符串“" << str << "”的哈希值为 " << hashStr << "\n"; // 字符串“Hello 算法”的哈希值为 15466937326284535026 -// 在 C++ 中,内置 std::hash() 仅提供基本数据类型的哈希值计算 +// 在 C++ 中,内置 std::hash() 仅提供基本数据类型和部分标准库类型(如 std::string)的哈希值计算 // 数组、对象的哈希值计算需要自行实现 ``` @@ -239,8 +239,8 @@ let node = ListNode::new(42); let mut node_hasher = DefaultHasher::new(); node.borrow().val.hash(&mut node_hasher); let hash_node = node_hasher.finish(); -println!("节点对象 {:?} 的哈希值为 {}", node, hash_node); -// 节点对象 RefCell { value: ListNode { val: 42, next: None } } 的哈希值为 15387811073369036852 +println!("节点 {:?} 中节点值的哈希值为 {}", node, hash_node); +// 节点 RefCell { value: ListNode { val: 42, next: None } } 中节点值的哈希值为 15387811073369036852 ``` ```c title="built_in_hash.c" diff --git a/codes/snippets/chapter_heap/heap.md b/codes/snippets/chapter_heap/heap.md index 78a2bea9b3..ce2791f8eb 100644 --- a/codes/snippets/chapter_heap/heap.md +++ b/codes/snippets/chapter_heap/heap.md @@ -160,7 +160,7 @@ func (h *intHeap) Push(x any) { *h = append(*h, x.(int)) } -// Pop heap.Interface 的函数,实现弹出堆顶元素 +// Pop heap.Interface 的函数,弹出切片末尾元素(heap.Pop 已将堆顶元素交换至末尾) func (h *intHeap) Pop() any { // 待出堆元素存放在最后 last := (*h)[len(*h)-1] @@ -201,7 +201,6 @@ func TestHeap(t *testing.T) { heap.Push(maxHeap, 2) heap.Push(maxHeap, 5) heap.Push(maxHeap, 4) - PrintHeap(*maxHeap) /* 获取堆顶元素 */ top := maxHeap.Top() diff --git a/en/codes/cpp/chapter_hashing/built_in_hash.cpp b/en/codes/cpp/chapter_hashing/built_in_hash.cpp index 276ad4de01..1c030a44ab 100644 --- a/en/codes/cpp/chapter_hashing/built_in_hash.cpp +++ b/en/codes/cpp/chapter_hashing/built_in_hash.cpp @@ -24,6 +24,6 @@ int main() { size_t hashStr = hash()(str); cout << "String " << str << " has hash value " << hashStr << "\n"; - // In C++, the built-in std::hash() only computes hash values for basic data types + // In C++, the built-in std::hash() only computes hash values for basic data types and some standard library types (such as std::string) // Hashing arrays and objects requires a custom implementation } diff --git a/en/codes/go/chapter_heap/heap.go b/en/codes/go/chapter_heap/heap.go index 6e26efcb4c..2666915487 100644 --- a/en/codes/go/chapter_heap/heap.go +++ b/en/codes/go/chapter_heap/heap.go @@ -15,7 +15,7 @@ func (h *intHeap) Push(x any) { *h = append(*h, x.(int)) } -// Pop is a heap.Interface function that pops the top element from the heap +// Pop is a heap.Interface function that pops the last element from the slice (heap.Pop has already swapped the top element of the heap to the end) func (h *intHeap) Pop() any { // The element to remove is stored at the end last := (*h)[len(*h)-1] diff --git a/en/codes/go/chapter_heap/top_k.go b/en/codes/go/chapter_heap/top_k.go index 4170891edd..63726d9478 100644 --- a/en/codes/go/chapter_heap/top_k.go +++ b/en/codes/go/chapter_heap/top_k.go @@ -17,7 +17,7 @@ func (h *minHeap) Push(x any) { *h = append(*h, x.(int)) } -// Pop implements heap.Interface by removing the last element, where heap.Pop has moved the top element +// Pop is a heap.Interface method that pops the last element from the slice (heap.Pop has already swapped the top element of the heap to the end) func (h *minHeap) Pop() any { // The element to remove is stored at the end last := (*h)[len(*h)-1] diff --git a/en/codes/go/chapter_stack_and_queue/stack_test.go b/en/codes/go/chapter_stack_and_queue/stack_test.go index ecb49bd78a..c8ab53f0e3 100644 --- a/en/codes/go/chapter_stack_and_queue/stack_test.go +++ b/en/codes/go/chapter_stack_and_queue/stack_test.go @@ -45,7 +45,7 @@ func TestStack(t *testing.T) { } func TestArrayStack(t *testing.T) { - // Initialize the stack and assign it to an interface + // Initialize the stack stack := newArrayStack() // Push elements onto the stack diff --git a/en/codes/rust/chapter_hashing/build_in_hash.rs b/en/codes/rust/chapter_hashing/build_in_hash.rs index 2f688465b7..4b5c636d53 100644 --- a/en/codes/rust/chapter_hashing/build_in_hash.rs +++ b/en/codes/rust/chapter_hashing/build_in_hash.rs @@ -45,5 +45,5 @@ fn main() { let mut hasher = DefaultHasher::new(); node.borrow().val.hash(&mut hasher); let hash = hasher.finish(); - println!("Node object {:?} has hash value {}", node, hash); + println!("The value in node {:?} has hash value {}", node, hash); } diff --git a/en/codes/snippets/chapter_hashing/hash_algorithm.md b/en/codes/snippets/chapter_hashing/hash_algorithm.md index 136d505713..76be30c30b 100644 --- a/en/codes/snippets/chapter_hashing/hash_algorithm.md +++ b/en/codes/snippets/chapter_hashing/hash_algorithm.md @@ -52,7 +52,7 @@ size_t hashStr = hash()(str); cout << "String '" << str << "' has hash value " << hashStr << "\n"; // String 'Hello 算法' has hash value 15466937326284535026 -// In C++, the built-in std::hash() only computes hash values for basic data types +// In C++, the built-in std::hash() only computes hash values for basic data types and some standard library types (such as std::string) // Hashing arrays and objects requires a custom implementation ``` @@ -239,8 +239,8 @@ let node = ListNode::new(42); let mut node_hasher = DefaultHasher::new(); node.borrow().val.hash(&mut node_hasher); let hash_node = node_hasher.finish(); -println!("Node object {:?} has hash value {}", node, hash_node); -// Node object RefCell { value: ListNode { val: 42, next: None } } has hash value 15387811073369036852 +println!("The value in node {:?} has hash value {}", node, hash_node); +// The value in node RefCell { value: ListNode { val: 42, next: None } } has hash value 15387811073369036852 ``` ```c title="built_in_hash.c" diff --git a/en/codes/snippets/chapter_heap/heap.md b/en/codes/snippets/chapter_heap/heap.md index afb390e45c..839b135287 100644 --- a/en/codes/snippets/chapter_heap/heap.md +++ b/en/codes/snippets/chapter_heap/heap.md @@ -160,7 +160,7 @@ func (h *intHeap) Push(x any) { *h = append(*h, x.(int)) } -// Pop is a heap.Interface function that pops the top element from the heap +// Pop is a heap.Interface function that pops the last element from the slice (heap.Pop has already swapped the top element of the heap to the end) func (h *intHeap) Pop() any { // The element to remove is stored at the end last := (*h)[len(*h)-1] @@ -201,7 +201,6 @@ func TestHeap(t *testing.T) { heap.Push(maxHeap, 2) heap.Push(maxHeap, 5) heap.Push(maxHeap, 4) - PrintHeap(*maxHeap) /* Get the top element of the heap */ top := maxHeap.Top() diff --git a/ja/codes/cpp/chapter_hashing/built_in_hash.cpp b/ja/codes/cpp/chapter_hashing/built_in_hash.cpp index 62a20bcf20..a81aeab8d9 100644 --- a/ja/codes/cpp/chapter_hashing/built_in_hash.cpp +++ b/ja/codes/cpp/chapter_hashing/built_in_hash.cpp @@ -24,6 +24,6 @@ int main() { size_t hashStr = hash()(str); cout << "文字列 " << str << " のハッシュ値は " << hashStr << "\n"; - // C++ の組み込み std::hash() は、基本データ型のハッシュ値の計算にのみ対応する + // C++ の組み込み std::hash() は、基本データ型と標準ライブラリの一部の型(std::string など)のハッシュ値の計算にのみ対応する // 配列やオブジェクトのハッシュ値の計算は自分で実装する必要がある } diff --git a/ja/codes/go/chapter_heap/heap.go b/ja/codes/go/chapter_heap/heap.go index d8a7fd2cb2..8736708547 100644 --- a/ja/codes/go/chapter_heap/heap.go +++ b/ja/codes/go/chapter_heap/heap.go @@ -15,7 +15,7 @@ func (h *intHeap) Push(x any) { *h = append(*h, x.(int)) } -// Pop は heap.Interface の関数であり、ヒープの先頭要素の取り出しを実装する +// Pop は heap.Interface の関数であり、スライスの末尾要素を取り出す(heap.Pop がすでにヒープの先頭要素と末尾要素を交換している) func (h *intHeap) Pop() any { // 取り出す要素は末尾に格納されている last := (*h)[len(*h)-1] diff --git a/ja/codes/go/chapter_heap/top_k.go b/ja/codes/go/chapter_heap/top_k.go index 66f2bdda6e..cc503c401d 100644 --- a/ja/codes/go/chapter_heap/top_k.go +++ b/ja/codes/go/chapter_heap/top_k.go @@ -17,7 +17,7 @@ func (h *minHeap) Push(x any) { *h = append(*h, x.(int)) } -// Pop は heap.Interface のメソッドであり、ヒープの先頭要素の取り出しを実装する +// Pop は heap.Interface のメソッドであり、スライスの末尾要素を取り出す(heap.Pop がすでにヒープの先頭要素と末尾要素を交換している) func (h *minHeap) Pop() any { // 取り出す要素は末尾に格納されている last := (*h)[len(*h)-1] diff --git a/ja/codes/go/chapter_stack_and_queue/stack_test.go b/ja/codes/go/chapter_stack_and_queue/stack_test.go index f9186af3c8..e83d5ce13d 100644 --- a/ja/codes/go/chapter_stack_and_queue/stack_test.go +++ b/ja/codes/go/chapter_stack_and_queue/stack_test.go @@ -45,7 +45,7 @@ func TestStack(t *testing.T) { } func TestArrayStack(t *testing.T) { - // スタックを初期化し、インターフェースで受け取る + // スタックを初期化する stack := newArrayStack() // 要素をプッシュする diff --git a/ja/codes/rust/chapter_hashing/build_in_hash.rs b/ja/codes/rust/chapter_hashing/build_in_hash.rs index 3c49635de4..98dd46840b 100644 --- a/ja/codes/rust/chapter_hashing/build_in_hash.rs +++ b/ja/codes/rust/chapter_hashing/build_in_hash.rs @@ -45,5 +45,5 @@ fn main() { let mut hasher = DefaultHasher::new(); node.borrow().val.hash(&mut hasher); let hash = hasher.finish(); - println!("ノードオブジェクト {:?} のハッシュ値は {}", node, hash); + println!("ノード {:?} の値のハッシュ値は {}", node, hash); } diff --git a/ja/codes/snippets/chapter_hashing/hash_algorithm.md b/ja/codes/snippets/chapter_hashing/hash_algorithm.md index ac2f5a85f0..bbb0fdf22e 100644 --- a/ja/codes/snippets/chapter_hashing/hash_algorithm.md +++ b/ja/codes/snippets/chapter_hashing/hash_algorithm.md @@ -52,7 +52,7 @@ size_t hashStr = hash()(str); cout << "文字列「" << str << "」のハッシュ値は " << hashStr << "\n"; // 文字列「Hello 算法」のハッシュ値は 15466937326284535026 -// C++ の組み込み std::hash() は、基本データ型のハッシュ値の計算にのみ対応する +// C++ の組み込み std::hash() は、基本データ型と標準ライブラリの一部の型(std::string など)のハッシュ値の計算にのみ対応する // 配列やオブジェクトのハッシュ値の計算は自分で実装する必要がある ``` @@ -239,8 +239,8 @@ let node = ListNode::new(42); let mut node_hasher = DefaultHasher::new(); node.borrow().val.hash(&mut node_hasher); let hash_node = node_hasher.finish(); -println!("ノードオブジェクト {:?} のハッシュ値は {}", node, hash_node); -// ノードオブジェクト RefCell { value: ListNode { val: 42, next: None } } のハッシュ値は 15387811073369036852 +println!("ノード {:?} の値のハッシュ値は {}", node, hash_node); +// ノード RefCell { value: ListNode { val: 42, next: None } } の値のハッシュ値は 15387811073369036852 ``` ```c title="built_in_hash.c" diff --git a/ja/codes/snippets/chapter_heap/heap.md b/ja/codes/snippets/chapter_heap/heap.md index 2e7925cde3..da5e34b0d6 100644 --- a/ja/codes/snippets/chapter_heap/heap.md +++ b/ja/codes/snippets/chapter_heap/heap.md @@ -160,7 +160,7 @@ func (h *intHeap) Push(x any) { *h = append(*h, x.(int)) } -// Pop は heap.Interface の関数であり、ヒープの先頭要素の取り出しを実装する +// Pop は heap.Interface の関数であり、スライスの末尾要素を取り出す(heap.Pop がすでにヒープの先頭要素と末尾要素を交換している) func (h *intHeap) Pop() any { // 取り出す要素は末尾に格納されている last := (*h)[len(*h)-1] @@ -201,7 +201,6 @@ func TestHeap(t *testing.T) { heap.Push(maxHeap, 2) heap.Push(maxHeap, 5) heap.Push(maxHeap, 4) - PrintHeap(*maxHeap) /* ヒープの先頭要素を取得する */ top := maxHeap.Top() diff --git a/ko/codes/cpp/chapter_hashing/built_in_hash.cpp b/ko/codes/cpp/chapter_hashing/built_in_hash.cpp index 4bb423f0cd..5e5a468b1e 100644 --- a/ko/codes/cpp/chapter_hashing/built_in_hash.cpp +++ b/ko/codes/cpp/chapter_hashing/built_in_hash.cpp @@ -24,6 +24,6 @@ int main() { size_t hashStr = hash()(str); cout << "문자열 " << str << " → 해시값: " << hashStr << "\n"; - // C++의 내장 std::hash()는 기본 데이터 타입에 대한 해시값 계산만 제공한다 + // C++의 내장 std::hash()는 기본 데이터 타입과 일부 표준 라이브러리 타입(예: std::string)에 대한 해시값 계산만 제공한다 // 배열과 객체의 해시값 계산은 직접 구현해야 한다 } diff --git a/ko/codes/go/chapter_heap/heap.go b/ko/codes/go/chapter_heap/heap.go index 88bd096a39..39ebcd2a3d 100644 --- a/ko/codes/go/chapter_heap/heap.go +++ b/ko/codes/go/chapter_heap/heap.go @@ -15,7 +15,7 @@ func (h *intHeap) Push(x any) { *h = append(*h, x.(int)) } -// Pop: heap.Interface의 함수로, 힙의 루트 원소를 꺼낸다 +// Pop: heap.Interface의 함수로, 슬라이스의 마지막 원소를 꺼낸다(heap.Pop이 이미 힙의 루트 원소를 교환하여 맨 뒤로 옮겼다) func (h *intHeap) Pop() any { // 꺼낼 원소는 맨 마지막에 저장되어 있다 last := (*h)[len(*h)-1] diff --git a/ko/codes/go/chapter_heap/top_k.go b/ko/codes/go/chapter_heap/top_k.go index 19feda7c66..99112745ac 100644 --- a/ko/codes/go/chapter_heap/top_k.go +++ b/ko/codes/go/chapter_heap/top_k.go @@ -17,7 +17,7 @@ func (h *minHeap) Push(x any) { *h = append(*h, x.(int)) } -// Pop: heap.Interface의 메서드로, 힙의 루트 원소를 꺼낸다 +// Pop: heap.Interface의 메서드로, 슬라이스의 마지막 원소를 꺼낸다(heap.Pop이 이미 힙의 루트 원소를 교환하여 맨 뒤로 옮겼다) func (h *minHeap) Pop() any { // 꺼낼 원소는 맨 마지막에 저장되어 있다 last := (*h)[len(*h)-1] diff --git a/ko/codes/go/chapter_stack_and_queue/stack_test.go b/ko/codes/go/chapter_stack_and_queue/stack_test.go index bc40d2bd9f..abc324442d 100644 --- a/ko/codes/go/chapter_stack_and_queue/stack_test.go +++ b/ko/codes/go/chapter_stack_and_queue/stack_test.go @@ -45,7 +45,7 @@ func TestStack(t *testing.T) { } func TestArrayStack(t *testing.T) { - // 스택을 초기화하고 인터페이스로 받는다 + // 스택 초기화 stack := newArrayStack() // 스택에 원소 삽입 diff --git a/ko/codes/rust/chapter_hashing/build_in_hash.rs b/ko/codes/rust/chapter_hashing/build_in_hash.rs index 904ad40e27..65e1b6ab4c 100644 --- a/ko/codes/rust/chapter_hashing/build_in_hash.rs +++ b/ko/codes/rust/chapter_hashing/build_in_hash.rs @@ -45,5 +45,5 @@ fn main() { let mut hasher = DefaultHasher::new(); node.borrow().val.hash(&mut hasher); let hash = hasher.finish(); - println!("노드 객체 {:?} → 해시값: {}", node, hash); + println!("노드 {:?}의 값 → 해시값: {}", node, hash); } diff --git a/ko/codes/snippets/chapter_hashing/hash_algorithm.md b/ko/codes/snippets/chapter_hashing/hash_algorithm.md index 1910ed7e13..1b494784a2 100644 --- a/ko/codes/snippets/chapter_hashing/hash_algorithm.md +++ b/ko/codes/snippets/chapter_hashing/hash_algorithm.md @@ -52,7 +52,7 @@ size_t hashStr = hash()(str); cout << "문자열 ‘" << str << "’ → 해시값: " << hashStr << "\n"; // 문자열 ‘Hello 算法’ → 해시값: 15466937326284535026 -// C++의 내장 std::hash()는 기본 데이터 타입에 대한 해시값 계산만 제공한다 +// C++의 내장 std::hash()는 기본 데이터 타입과 일부 표준 라이브러리 타입(예: std::string)에 대한 해시값 계산만 제공한다 // 배열과 객체의 해시값 계산은 직접 구현해야 한다 ``` @@ -239,8 +239,8 @@ let node = ListNode::new(42); let mut node_hasher = DefaultHasher::new(); node.borrow().val.hash(&mut node_hasher); let hash_node = node_hasher.finish(); -println!("노드 객체 {:?} → 해시값: {}", node, hash_node); -// 노드 객체 RefCell { value: ListNode { val: 42, next: None } } → 해시값: 15387811073369036852 +println!("노드 {:?}의 값 → 해시값: {}", node, hash_node); +// 노드 RefCell { value: ListNode { val: 42, next: None } }의 값 → 해시값: 15387811073369036852 ``` ```c title="built_in_hash.c" diff --git a/ko/codes/snippets/chapter_heap/heap.md b/ko/codes/snippets/chapter_heap/heap.md index 48b45ca126..b1f694c8ff 100644 --- a/ko/codes/snippets/chapter_heap/heap.md +++ b/ko/codes/snippets/chapter_heap/heap.md @@ -160,7 +160,7 @@ func (h *intHeap) Push(x any) { *h = append(*h, x.(int)) } -// Pop: heap.Interface의 함수로, 힙의 루트 원소를 꺼낸다 +// Pop: heap.Interface의 함수로, 슬라이스의 마지막 원소를 꺼낸다(heap.Pop이 이미 힙의 루트 원소를 교환하여 맨 뒤로 옮겼다) func (h *intHeap) Pop() any { // 꺼낼 원소는 맨 마지막에 저장되어 있다 last := (*h)[len(*h)-1] @@ -201,7 +201,6 @@ func TestHeap(t *testing.T) { heap.Push(maxHeap, 2) heap.Push(maxHeap, 5) heap.Push(maxHeap, 4) - PrintHeap(*maxHeap) /* 힙의 루트 원소 반환 */ top := maxHeap.Top() diff --git a/ru/codes/cpp/chapter_hashing/built_in_hash.cpp b/ru/codes/cpp/chapter_hashing/built_in_hash.cpp index 55d3d1d385..7591f6b758 100644 --- a/ru/codes/cpp/chapter_hashing/built_in_hash.cpp +++ b/ru/codes/cpp/chapter_hashing/built_in_hash.cpp @@ -24,6 +24,6 @@ int main() { size_t hashStr = hash()(str); cout << "Хеш-значение строки " << str << " = " << hashStr << "\n"; - // В C++ встроенный std::hash() предоставляет вычисление хеша только для базовых типов данных + // В C++ встроенный std::hash() предоставляет вычисление хеша только для базовых типов данных и некоторых типов стандартной библиотеки (например, std::string) // Вычисление хеша для массивов и объектов нужно реализовывать самостоятельно } diff --git a/ru/codes/go/chapter_heap/heap.go b/ru/codes/go/chapter_heap/heap.go index b5ef628e0c..d90315712b 100644 --- a/ru/codes/go/chapter_heap/heap.go +++ b/ru/codes/go/chapter_heap/heap.go @@ -15,7 +15,7 @@ func (h *intHeap) Push(x any) { *h = append(*h, x.(int)) } -// Функция Pop интерфейса heap.Interface, реализующая извлечение элемента с вершины кучи +// Функция Pop интерфейса heap.Interface: извлекает последний элемент среза (heap.Pop заранее перемещает вершину кучи в конец) func (h *intHeap) Pop() any { // Элемент, который нужно удалить из кучи, хранится в конце last := (*h)[len(*h)-1] diff --git a/ru/codes/go/chapter_heap/top_k.go b/ru/codes/go/chapter_heap/top_k.go index d1cb01dd1a..d1adefa11a 100644 --- a/ru/codes/go/chapter_heap/top_k.go +++ b/ru/codes/go/chapter_heap/top_k.go @@ -17,7 +17,7 @@ func (h *minHeap) Push(x any) { *h = append(*h, x.(int)) } -// Метод Pop интерфейса heap.Interface, реализующий извлечение элемента с вершины кучи +// Метод Pop интерфейса heap.Interface: извлекает последний элемент среза (heap.Pop заранее перемещает вершину кучи в конец) func (h *minHeap) Pop() any { // Элемент, который нужно удалить из кучи, хранится в конце last := (*h)[len(*h)-1] diff --git a/ru/codes/go/chapter_stack_and_queue/stack_test.go b/ru/codes/go/chapter_stack_and_queue/stack_test.go index d170ef05f5..15970194f1 100644 --- a/ru/codes/go/chapter_stack_and_queue/stack_test.go +++ b/ru/codes/go/chapter_stack_and_queue/stack_test.go @@ -45,7 +45,7 @@ func TestStack(t *testing.T) { } func TestArrayStack(t *testing.T) { - // Инициализировать стек, используя интерфейс + // Инициализировать стек stack := newArrayStack() // Помещение элемента в стек diff --git a/ru/codes/rust/chapter_hashing/build_in_hash.rs b/ru/codes/rust/chapter_hashing/build_in_hash.rs index 60a1a2eee1..4ad23648bf 100644 --- a/ru/codes/rust/chapter_hashing/build_in_hash.rs +++ b/ru/codes/rust/chapter_hashing/build_in_hash.rs @@ -45,5 +45,5 @@ fn main() { let mut hasher = DefaultHasher::new(); node.borrow().val.hash(&mut hasher); let hash = hasher.finish(); - println!("Хеш-значение объекта узла {:?} = {}", node, hash); + println!("Хеш-значение значения в узле {:?} = {}", node, hash); } diff --git a/ru/codes/snippets/chapter_hashing/hash_algorithm.md b/ru/codes/snippets/chapter_hashing/hash_algorithm.md index f95a2b1dcc..e63cbfcc22 100644 --- a/ru/codes/snippets/chapter_hashing/hash_algorithm.md +++ b/ru/codes/snippets/chapter_hashing/hash_algorithm.md @@ -52,7 +52,7 @@ size_t hashStr = hash()(str); cout << "Хеш-значение строки «" << str << "» = " << hashStr << "\n"; // Хеш-значение строки «Hello Algo» = 15466937326284535026 -// В C++ встроенный std::hash() предоставляет вычисление хеша только для базовых типов данных +// В C++ встроенный std::hash() предоставляет вычисление хеша только для базовых типов данных и некоторых типов стандартной библиотеки (например, std::string) // Вычисление хеша для массивов и объектов нужно реализовывать самостоятельно ``` @@ -239,8 +239,8 @@ let node = ListNode::new(42); let mut node_hasher = DefaultHasher::new(); node.borrow().val.hash(&mut node_hasher); let hash_node = node_hasher.finish(); -println!("Хеш-значение объекта узла {:?} = {}", node, hash_node); -// Хеш-значение объекта узла RefCell { value: ListNode { val: 42, next: None } } = 15387811073369036852 +println!("Хеш-значение значения в узле {:?} = {}", node, hash_node); +// Хеш-значение значения в узле RefCell { value: ListNode { val: 42, next: None } } = 15387811073369036852 ``` ```c title="built_in_hash.c" diff --git a/ru/codes/snippets/chapter_heap/heap.md b/ru/codes/snippets/chapter_heap/heap.md index 5669603763..aeaa34d892 100644 --- a/ru/codes/snippets/chapter_heap/heap.md +++ b/ru/codes/snippets/chapter_heap/heap.md @@ -160,7 +160,7 @@ func (h *intHeap) Push(x any) { *h = append(*h, x.(int)) } -// Функция Pop интерфейса heap.Interface, реализующая извлечение элемента с вершины кучи +// Функция Pop интерфейса heap.Interface: извлекает последний элемент среза (heap.Pop заранее перемещает вершину кучи в конец) func (h *intHeap) Pop() any { // Элемент, который нужно удалить из кучи, хранится в конце last := (*h)[len(*h)-1] @@ -201,7 +201,6 @@ func TestHeap(t *testing.T) { heap.Push(maxHeap, 2) heap.Push(maxHeap, 5) heap.Push(maxHeap, 4) - PrintHeap(*maxHeap) /* Получение элемента с вершины кучи */ top := maxHeap.Top() diff --git a/zh-hant/codes/cpp/chapter_hashing/built_in_hash.cpp b/zh-hant/codes/cpp/chapter_hashing/built_in_hash.cpp index 8804a475d5..d53f9838eb 100644 --- a/zh-hant/codes/cpp/chapter_hashing/built_in_hash.cpp +++ b/zh-hant/codes/cpp/chapter_hashing/built_in_hash.cpp @@ -24,6 +24,6 @@ int main() { size_t hashStr = hash()(str); cout << "字串 " << str << " 的雜湊值為 " << hashStr << "\n"; - // 在 C++ 中,內建 std::hash() 僅提供基本資料型別的雜湊值計算 + // 在 C++ 中,內建 std::hash() 僅提供基本資料型別和部分標準庫型別(如 std::string)的雜湊值計算 // 陣列、物件的雜湊值計算需要自行實現 } diff --git a/zh-hant/codes/go/chapter_heap/heap.go b/zh-hant/codes/go/chapter_heap/heap.go index 765556a49a..bb754caad1 100644 --- a/zh-hant/codes/go/chapter_heap/heap.go +++ b/zh-hant/codes/go/chapter_heap/heap.go @@ -15,7 +15,7 @@ func (h *intHeap) Push(x any) { *h = append(*h, x.(int)) } -// Pop heap.Interface 的函式,實現彈出堆積頂元素 +// Pop heap.Interface 的函式,彈出切片末尾元素(heap.Pop 已將堆積頂元素交換至末尾) func (h *intHeap) Pop() any { // 待出堆積元素存放在最後 last := (*h)[len(*h)-1] diff --git a/zh-hant/codes/go/chapter_heap/top_k.go b/zh-hant/codes/go/chapter_heap/top_k.go index 21a4bb7acd..5d7f2f19b4 100644 --- a/zh-hant/codes/go/chapter_heap/top_k.go +++ b/zh-hant/codes/go/chapter_heap/top_k.go @@ -17,7 +17,7 @@ func (h *minHeap) Push(x any) { *h = append(*h, x.(int)) } -// Pop heap.Interface 的方法,實現彈出堆積頂元素 +// Pop heap.Interface 的方法,彈出切片末尾元素(heap.Pop 已將堆積頂元素交換至末尾) func (h *minHeap) Pop() any { // 待出堆積元素存放在最後 last := (*h)[len(*h)-1] diff --git a/zh-hant/codes/go/chapter_stack_and_queue/stack_test.go b/zh-hant/codes/go/chapter_stack_and_queue/stack_test.go index 3a5a9e0b0b..870c6a1a0f 100644 --- a/zh-hant/codes/go/chapter_stack_and_queue/stack_test.go +++ b/zh-hant/codes/go/chapter_stack_and_queue/stack_test.go @@ -45,7 +45,7 @@ func TestStack(t *testing.T) { } func TestArrayStack(t *testing.T) { - // 初始化堆疊, 使用介面承接 + // 初始化堆疊 stack := newArrayStack() // 元素入堆疊 diff --git a/zh-hant/codes/rust/chapter_hashing/build_in_hash.rs b/zh-hant/codes/rust/chapter_hashing/build_in_hash.rs index cd74117e8b..44a71d8e25 100644 --- a/zh-hant/codes/rust/chapter_hashing/build_in_hash.rs +++ b/zh-hant/codes/rust/chapter_hashing/build_in_hash.rs @@ -45,5 +45,5 @@ fn main() { let mut hasher = DefaultHasher::new(); node.borrow().val.hash(&mut hasher); let hash = hasher.finish(); - println!("節點物件 {:?} 的雜湊值為 {}", node, hash); + println!("節點 {:?} 中節點值的雜湊值為 {}", node, hash); } diff --git a/zh-hant/codes/snippets/chapter_hashing/hash_algorithm.md b/zh-hant/codes/snippets/chapter_hashing/hash_algorithm.md index 2405ed69fd..041681de48 100644 --- a/zh-hant/codes/snippets/chapter_hashing/hash_algorithm.md +++ b/zh-hant/codes/snippets/chapter_hashing/hash_algorithm.md @@ -52,7 +52,7 @@ size_t hashStr = hash()(str); cout << "字串“" << str << "”的雜湊值為 " << hashStr << "\n"; // 字串“Hello 演算法”的雜湊值為 15466937326284535026 -// 在 C++ 中,內建 std::hash() 僅提供基本資料型別的雜湊值計算 +// 在 C++ 中,內建 std::hash() 僅提供基本資料型別和部分標準庫型別(如 std::string)的雜湊值計算 // 陣列、物件的雜湊值計算需要自行實現 ``` @@ -75,7 +75,7 @@ System.out.println("小數 " + dec + " 的雜湊值為 " + hashDec); String str = "Hello 演算法"; int hashStr = str.hashCode(); System.out.println("字串“" + str + "”的雜湊值為 " + hashStr); -// 字串“Hello 演算法”的雜湊值為 -727081396 +// 字串“Hello 演算法”的雜湊值為 -1067619900 Object[] arr = { 12836, "小哈" }; int hashArr = Arrays.hashCode(arr); @@ -183,7 +183,7 @@ print("小數 $dec 的雜湊值為 $hashDec"); String str = "Hello 演算法"; int hashStr = str.hashCode; print("字串“$str”的雜湊值為 $hashStr"); -// 字串“Hello 演算法”的雜湊值為 468167534 +// 字串“Hello 演算法”的雜湊值為 544745643 List arr = [12836, "小哈"]; int hashArr = arr.hashCode; @@ -226,7 +226,7 @@ let mut str_hasher = DefaultHasher::new(); str.hash(&mut str_hasher); let hash_str = str_hasher.finish(); println!("字串“{}”的雜湊值為 {}", str, hash_str); -// 字串“Hello 演算法”的雜湊值為 16092673739211250988 +// 字串“Hello 演算法”的雜湊值為 14554651044579956997 let tup = (&12836, &"小哈"); let mut tup_hasher = DefaultHasher::new(); @@ -239,8 +239,8 @@ let node = ListNode::new(42); let mut node_hasher = DefaultHasher::new(); node.borrow().val.hash(&mut node_hasher); let hash_node = node_hasher.finish(); -println!("節點物件 {:?} 的雜湊值為 {}", node, hash_node); -// 節點物件 RefCell { value: ListNode { val: 42, next: None } } 的雜湊值為 15387811073369036852 +println!("節點 {:?} 中節點值的雜湊值為 {}", node, hash_node); +// 節點 RefCell { value: ListNode { val: 42, next: None } } 中節點值的雜湊值為 15387811073369036852 ``` ```c title="built_in_hash.c" @@ -266,7 +266,7 @@ println("小數 $dec 的雜湊值為 $hashDec") val str = "Hello 演算法" val hashStr = str.hashCode() println("字串“$str”的雜湊值為 $hashStr") -// 字串“Hello 演算法”的雜湊值為 -727081396 +// 字串“Hello 演算法”的雜湊值為 -1067619900 val arr = arrayOf(12836, "小哈") val hashArr = arr.contentHashCode() diff --git a/zh-hant/codes/snippets/chapter_heap/heap.md b/zh-hant/codes/snippets/chapter_heap/heap.md index 57610d0570..d6eb166932 100644 --- a/zh-hant/codes/snippets/chapter_heap/heap.md +++ b/zh-hant/codes/snippets/chapter_heap/heap.md @@ -160,7 +160,7 @@ func (h *intHeap) Push(x any) { *h = append(*h, x.(int)) } -// Pop heap.Interface 的函式,實現彈出堆積頂元素 +// Pop heap.Interface 的函式,彈出切片末尾元素(heap.Pop 已將堆積頂元素交換至末尾) func (h *intHeap) Pop() any { // 待出堆積元素存放在最後 last := (*h)[len(*h)-1] @@ -201,7 +201,6 @@ func TestHeap(t *testing.T) { heap.Push(maxHeap, 2) heap.Push(maxHeap, 5) heap.Push(maxHeap, 4) - PrintHeap(*maxHeap) /* 獲取堆積頂元素 */ top := maxHeap.Top()