From 518b9efabc3b29a09e94f499690d4b9adb878ed1 Mon Sep 17 00:00:00 2001 From: krahets Date: Wed, 15 Mar 2023 03:48:31 +0800 Subject: [PATCH] Update a comment in array_hash_map --- codes/cpp/chapter_hashing/array_hash_map.cpp | 4 ++-- codes/csharp/chapter_hashing/array_hash_map.cs | 2 +- codes/go/chapter_hashing/array_hash_map.go | 2 +- codes/java/chapter_hashing/array_hash_map.java | 2 +- codes/javascript/chapter_hashing/array_hash_map.js | 2 +- codes/python/chapter_hashing/array_hash_map.py | 2 +- codes/rust/chapter_hashing/array_hash_map.rs | 2 +- codes/swift/chapter_hashing/array_hash_map.swift | 2 +- codes/typescript/chapter_hashing/array_hash_map.ts | 2 +- codes/zig/chapter_hashing/array_hash_map.zig | 2 +- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/codes/cpp/chapter_hashing/array_hash_map.cpp b/codes/cpp/chapter_hashing/array_hash_map.cpp index 1527e952e..d72121b33 100644 --- a/codes/cpp/chapter_hashing/array_hash_map.cpp +++ b/codes/cpp/chapter_hashing/array_hash_map.cpp @@ -23,8 +23,8 @@ private: vector buckets; public: ArrayHashMap() { - // 初始化一个长度为 100 的桶(数组) - buckets= vector(100); + // 初始化数组,包含 100 个桶 + buckets = vector(100); } /* 哈希函数 */ diff --git a/codes/csharp/chapter_hashing/array_hash_map.cs b/codes/csharp/chapter_hashing/array_hash_map.cs index 56a87846c..d9ba14e92 100644 --- a/codes/csharp/chapter_hashing/array_hash_map.cs +++ b/codes/csharp/chapter_hashing/array_hash_map.cs @@ -26,7 +26,7 @@ class ArrayHashMap private List buckets; public ArrayHashMap() { - // 初始化一个长度为 100 的桶(数组) + // 初始化数组,包含 100 个桶 buckets = new(); for (int i = 0; i < 100; i++) { diff --git a/codes/go/chapter_hashing/array_hash_map.go b/codes/go/chapter_hashing/array_hash_map.go index 12c2613de..22b886e2e 100644 --- a/codes/go/chapter_hashing/array_hash_map.go +++ b/codes/go/chapter_hashing/array_hash_map.go @@ -19,7 +19,7 @@ type arrayHashMap struct { /* 初始化哈希表 */ func newArrayHashMap() *arrayHashMap { - // 初始化一个长度为 100 的桶(数组) + // 初始化数组,包含 100 个桶 buckets := make([]*entry, 100) return &arrayHashMap{buckets: buckets} } diff --git a/codes/java/chapter_hashing/array_hash_map.java b/codes/java/chapter_hashing/array_hash_map.java index c8ac64c35..b1ae7d6a1 100644 --- a/codes/java/chapter_hashing/array_hash_map.java +++ b/codes/java/chapter_hashing/array_hash_map.java @@ -22,7 +22,7 @@ class Entry { class ArrayHashMap { private List buckets; public ArrayHashMap() { - // 初始化一个长度为 100 的桶(数组) + // 初始化数组,包含 100 个桶 buckets = new ArrayList<>(); for (int i = 0; i < 100; i++) { buckets.add(null); diff --git a/codes/javascript/chapter_hashing/array_hash_map.js b/codes/javascript/chapter_hashing/array_hash_map.js index 63120ac15..7e161159c 100644 --- a/codes/javascript/chapter_hashing/array_hash_map.js +++ b/codes/javascript/chapter_hashing/array_hash_map.js @@ -16,7 +16,7 @@ class Entry { class ArrayHashMap { #buckets; constructor() { - // 初始化一个长度为 100 的桶(数组) + // 初始化数组,包含 100 个桶 this.#buckets = new Array(100).fill(null); } diff --git a/codes/python/chapter_hashing/array_hash_map.py b/codes/python/chapter_hashing/array_hash_map.py index 148a79050..1a2cbe87d 100644 --- a/codes/python/chapter_hashing/array_hash_map.py +++ b/codes/python/chapter_hashing/array_hash_map.py @@ -18,7 +18,7 @@ class ArrayHashMap: """ 基于数组简易实现的哈希表 """ def __init__(self): """ 构造方法 """ - # 初始化一个长度为 100 的桶(数组) + # 初始化数组,包含 100 个桶 self.buckets: List[Optional[Entry]] = [None] * 100 def hash_func(self, key: int) -> int: diff --git a/codes/rust/chapter_hashing/array_hash_map.rs b/codes/rust/chapter_hashing/array_hash_map.rs index b0789a7eb..59857fced 100644 --- a/codes/rust/chapter_hashing/array_hash_map.rs +++ b/codes/rust/chapter_hashing/array_hash_map.rs @@ -16,7 +16,7 @@ pub struct ArrayHashMap { buckets: Vec> } impl ArrayHashMap { pub fn new() -> ArrayHashMap { - // 初始化一个长度为 100 的桶(数组) + // 初始化数组,包含 100 个桶 Self { buckets: vec![None; 100] } } diff --git a/codes/swift/chapter_hashing/array_hash_map.swift b/codes/swift/chapter_hashing/array_hash_map.swift index 9517df0b4..fc9438037 100644 --- a/codes/swift/chapter_hashing/array_hash_map.swift +++ b/codes/swift/chapter_hashing/array_hash_map.swift @@ -20,7 +20,7 @@ class ArrayHashMap { private var buckets: [Entry?] = [] init() { - // 初始化一个长度为 100 的桶(数组) + // 初始化数组,包含 100 个桶 for _ in 0 ..< 100 { buckets.append(nil) } diff --git a/codes/typescript/chapter_hashing/array_hash_map.ts b/codes/typescript/chapter_hashing/array_hash_map.ts index cbc6d0381..1a65850fa 100644 --- a/codes/typescript/chapter_hashing/array_hash_map.ts +++ b/codes/typescript/chapter_hashing/array_hash_map.ts @@ -21,7 +21,7 @@ class ArrayHashMap { private readonly buckets: (Entry | null)[]; constructor() { - // 初始化一个长度为 100 的桶(数组) + // 初始化数组,包含 100 个桶 this.buckets = (new Array(100)).fill(null); } diff --git a/codes/zig/chapter_hashing/array_hash_map.zig b/codes/zig/chapter_hashing/array_hash_map.zig index 388de5c4c..cbab80af8 100644 --- a/codes/zig/chapter_hashing/array_hash_map.zig +++ b/codes/zig/chapter_hashing/array_hash_map.zig @@ -29,7 +29,7 @@ pub fn ArrayHashMap(comptime T: type) type { // 构造方法 pub fn init(self: *Self, allocator: std.mem.Allocator) !void { self.mem_allocator = allocator; - // 初始化一个长度为 100 的桶(数组) + // 初始化数组,包含 100 个桶 self.buckets = std.ArrayList(?T).init(self.mem_allocator); var i: i32 = 0; while (i < 100) : (i += 1) {