This commit is contained in:
krahets
2023-07-31 03:27:06 +08:00
parent e0d4aed887
commit 3501592bbc
10 changed files with 627 additions and 257 deletions

View File

@@ -1383,7 +1383,7 @@ comments: true
if self.__size == self.capacity():
raise IndexError("队列已满")
# 计算尾指针,指向队尾索引 + 1
# 通过取余操作,实现 rear 越过数组尾部后回到头部F
# 通过取余操作,实现 rear 越过数组尾部后回到头部
rear: int = (self.__front + self.__size) % self.capacity()
# 将 num 添加至队尾
self.__nums[rear] = num