mirror of
https://github.com/krahets/hello-algo.git
synced 2025-01-23 14:20:29 +08:00
Update a comment in array_hash_map
This commit is contained in:
parent
d5afd93571
commit
518b9efabc
@ -23,7 +23,7 @@ private:
|
||||
vector<Entry*> buckets;
|
||||
public:
|
||||
ArrayHashMap() {
|
||||
// 初始化一个长度为 100 的桶(数组)
|
||||
// 初始化数组,包含 100 个桶
|
||||
buckets = vector<Entry*>(100);
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ class ArrayHashMap
|
||||
private List<Entry?> buckets;
|
||||
public ArrayHashMap()
|
||||
{
|
||||
// 初始化一个长度为 100 的桶(数组)
|
||||
// 初始化数组,包含 100 个桶
|
||||
buckets = new();
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
|
@ -19,7 +19,7 @@ type arrayHashMap struct {
|
||||
|
||||
/* 初始化哈希表 */
|
||||
func newArrayHashMap() *arrayHashMap {
|
||||
// 初始化一个长度为 100 的桶(数组)
|
||||
// 初始化数组,包含 100 个桶
|
||||
buckets := make([]*entry, 100)
|
||||
return &arrayHashMap{buckets: buckets}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ class Entry {
|
||||
class ArrayHashMap {
|
||||
private List<Entry> buckets;
|
||||
public ArrayHashMap() {
|
||||
// 初始化一个长度为 100 的桶(数组)
|
||||
// 初始化数组,包含 100 个桶
|
||||
buckets = new ArrayList<>();
|
||||
for (int i = 0; i < 100; i++) {
|
||||
buckets.add(null);
|
||||
|
@ -16,7 +16,7 @@ class Entry {
|
||||
class ArrayHashMap {
|
||||
#buckets;
|
||||
constructor() {
|
||||
// 初始化一个长度为 100 的桶(数组)
|
||||
// 初始化数组,包含 100 个桶
|
||||
this.#buckets = new Array(100).fill(null);
|
||||
}
|
||||
|
||||
|
@ -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:
|
||||
|
@ -16,7 +16,7 @@ pub struct ArrayHashMap { buckets: Vec<Option<Entry>> }
|
||||
|
||||
impl ArrayHashMap {
|
||||
pub fn new() -> ArrayHashMap {
|
||||
// 初始化一个长度为 100 的桶(数组)
|
||||
// 初始化数组,包含 100 个桶
|
||||
Self { buckets: vec![None; 100] }
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ class ArrayHashMap {
|
||||
private var buckets: [Entry?] = []
|
||||
|
||||
init() {
|
||||
// 初始化一个长度为 100 的桶(数组)
|
||||
// 初始化数组,包含 100 个桶
|
||||
for _ in 0 ..< 100 {
|
||||
buckets.append(nil)
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ class ArrayHashMap {
|
||||
private readonly buckets: (Entry | null)[];
|
||||
|
||||
constructor() {
|
||||
// 初始化一个长度为 100 的桶(数组)
|
||||
// 初始化数组,包含 100 个桶
|
||||
this.buckets = (new Array(100)).fill(null);
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user