From 6377e3316adc20446d23eb321152317a4e987de8 Mon Sep 17 00:00:00 2001 From: krahets Date: Sat, 3 Jun 2023 22:18:28 +0800 Subject: [PATCH] Fix a comment in my_list.xx --- codes/cpp/chapter_array_and_linkedlist/my_list.cpp | 2 +- codes/dart/chapter_array_and_linkedlist/my_list.dart | 2 +- codes/go/chapter_array_and_linkedlist/my_list.go | 2 +- codes/java/chapter_array_and_linkedlist/my_list.java | 2 +- codes/javascript/chapter_array_and_linkedlist/my_list.js | 2 +- codes/python/chapter_array_and_linkedlist/my_list.py | 2 +- codes/swift/chapter_array_and_linkedlist/my_list.swift | 2 +- codes/zig/chapter_array_and_linkedlist/my_list.zig | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/codes/cpp/chapter_array_and_linkedlist/my_list.cpp b/codes/cpp/chapter_array_and_linkedlist/my_list.cpp index 373393572..a35920aa3 100644 --- a/codes/cpp/chapter_array_and_linkedlist/my_list.cpp +++ b/codes/cpp/chapter_array_and_linkedlist/my_list.cpp @@ -93,7 +93,7 @@ class MyList { /* 列表扩容 */ void extendCapacity() { - // 新建一个长度为 size * extendRatio 的数组,并将原数组拷贝到新数组 + // 新建一个长度为原数组 extendRatio 倍的新数组 int newCapacity = capacity() * extendRatio; int *tmp = nums; nums = new int[newCapacity]; diff --git a/codes/dart/chapter_array_and_linkedlist/my_list.dart b/codes/dart/chapter_array_and_linkedlist/my_list.dart index d7d7d671d..688a9e820 100644 --- a/codes/dart/chapter_array_and_linkedlist/my_list.dart +++ b/codes/dart/chapter_array_and_linkedlist/my_list.dart @@ -73,7 +73,7 @@ class MyList { /* 列表扩容 */ void extendCapacity() { - // 新建一个长度为 _capacity * _extendRatio 的数组 + // 新建一个长度为原数组 _extendRatio 倍的新数组 final _newNums = List.filled(_capacity * _extendRatio, 0); // 将原数组拷贝到新数组 List.copyRange(_newNums, 0, _nums); diff --git a/codes/go/chapter_array_and_linkedlist/my_list.go b/codes/go/chapter_array_and_linkedlist/my_list.go index 46f52dc32..069e9513b 100644 --- a/codes/go/chapter_array_and_linkedlist/my_list.go +++ b/codes/go/chapter_array_and_linkedlist/my_list.go @@ -96,7 +96,7 @@ func (l *myList) remove(index int) int { /* 列表扩容 */ func (l *myList) extendCapacity() { - // 新建一个长度为 self.__size 的数组,并将原数组拷贝到新数组 + // 新建一个长度为原数组 extendRatio 倍的新数组,并将原数组拷贝到新数组 l.nums = append(l.nums, make([]int, l.numsCapacity*(l.extendRatio-1))...) // 更新列表容量 l.numsCapacity = len(l.nums) diff --git a/codes/java/chapter_array_and_linkedlist/my_list.java b/codes/java/chapter_array_and_linkedlist/my_list.java index 79ac4eb63..8a5acd4e5 100644 --- a/codes/java/chapter_array_and_linkedlist/my_list.java +++ b/codes/java/chapter_array_and_linkedlist/my_list.java @@ -88,7 +88,7 @@ class MyList { /* 列表扩容 */ public void extendCapacity() { - // 新建一个长度为 size 的数组,并将原数组拷贝到新数组 + // 新建一个长度为原数组 extendRatio 倍的新数组,并将原数组拷贝到新数组 nums = Arrays.copyOf(nums, capacity() * extendRatio); // 更新列表容量 capacity = nums.length; diff --git a/codes/javascript/chapter_array_and_linkedlist/my_list.js b/codes/javascript/chapter_array_and_linkedlist/my_list.js index b0705bddf..2ef56aabb 100644 --- a/codes/javascript/chapter_array_and_linkedlist/my_list.js +++ b/codes/javascript/chapter_array_and_linkedlist/my_list.js @@ -82,7 +82,7 @@ class MyList { /* 列表扩容 */ extendCapacity() { - // 新建一个长度为 size 的数组,并将原数组拷贝到新数组 + // 新建一个长度为原数组 extendRatio 倍的新数组,并将原数组拷贝到新数组 this.#nums = this.#nums.concat( new Array(this.capacity() * (this.#extendRatio - 1)) ); diff --git a/codes/python/chapter_array_and_linkedlist/my_list.py b/codes/python/chapter_array_and_linkedlist/my_list.py index 10ba62192..9e8749340 100644 --- a/codes/python/chapter_array_and_linkedlist/my_list.py +++ b/codes/python/chapter_array_and_linkedlist/my_list.py @@ -73,7 +73,7 @@ class MyList: def extend_capacity(self) -> None: """列表扩容""" - # 新建一个长度为 self.__size 的数组,并将原数组拷贝到新数组 + # 新建一个长度为原数组 __extend_ratio 倍的新数组,并将原数组拷贝到新数组 self.__nums = self.__nums + [0] * self.capacity() * (self.__extend_ratio - 1) # 更新列表容量 self.__capacity = len(self.__nums) diff --git a/codes/swift/chapter_array_and_linkedlist/my_list.swift b/codes/swift/chapter_array_and_linkedlist/my_list.swift index 6081237a8..2f5dfeb21 100644 --- a/codes/swift/chapter_array_and_linkedlist/my_list.swift +++ b/codes/swift/chapter_array_and_linkedlist/my_list.swift @@ -91,7 +91,7 @@ class MyList { /* 列表扩容 */ func extendCapacity() { - // 新建一个长度为 size 的数组,并将原数组拷贝到新数组 + // 新建一个长度为原数组 extendRatio 倍的新数组,并将原数组拷贝到新数组 nums = nums + Array(repeating: 0, count: _capacity * (extendRatio - 1)) // 更新列表容量 _capacity = nums.count diff --git a/codes/zig/chapter_array_and_linkedlist/my_list.zig b/codes/zig/chapter_array_and_linkedlist/my_list.zig index bdf76b8ff..78a530ed5 100644 --- a/codes/zig/chapter_array_and_linkedlist/my_list.zig +++ b/codes/zig/chapter_array_and_linkedlist/my_list.zig @@ -98,7 +98,7 @@ pub fn MyList(comptime T: type) type { // 列表扩容 pub fn extendCapacity(self: *Self) !void { - // 新建一个长度为 size * extend_ratio 的数组,并将原数组拷贝到新数组 + // 新建一个长度为原数组 extendRatio 倍的新数组,并将原数组拷贝到新数组 var newCapacity = self.capacity() * self.extend_ratio; var extend = try self.mem_allocator.alloc(T, newCapacity); std.mem.set(T, extend, @as(T, 0));