1. Remove Pair class from hash coliision code.

2. Fix the comment in my_list code.
3. Add a Q&A to the summary of sorting.
This commit is contained in:
krahets
2023-06-26 23:06:15 +08:00
parent 7876e3e88c
commit 54dc288e61
18 changed files with 81 additions and 152 deletions

View File

@@ -71,7 +71,7 @@ pub fn MyList(comptime T: type) type {
if (index < 0 or index >= self.size()) @panic("索引越界");
// 元素数量超出容量时,触发扩容机制
if (self.size() == self.capacity()) try self.extendCapacity();
// 索引 i 以及之后的元素都向后移动一位
// 索引 index 以及之后的元素都向后移动一位
var j = self.size() - 1;
while (j >= index) : (j -= 1) {
self.nums[j + 1] = self.nums[j];