refactor: Replace poll with pop in Queue and Deque (#415)

This commit is contained in:
Yudong Jin
2023-03-13 21:58:21 +08:00
committed by GitHub
parent 2d17ee8e92
commit 8aebbaad21
77 changed files with 261 additions and 261 deletions

View File

@ -38,7 +38,7 @@ class ArrayQueue:
self.__nums[rear] = num
self.__size += 1
def poll(self) -> int:
def pop(self) -> int:
""" 出队 """
num: int = self.peek()
# 队首指针向后移动一位,若越过尾部则返回到数组头部
@ -79,8 +79,8 @@ if __name__ == "__main__":
print("队首元素 peek =", peek)
""" 元素出队 """
poll: int = queue.poll()
print("出队元素 poll =", poll)
pop: int = queue.pop()
print("出队元素 pop =", pop)
print("出队后 queue =", queue.to_list())
""" 获取队列的长度 """
@ -94,5 +94,5 @@ if __name__ == "__main__":
""" 测试环形数组 """
for i in range(10):
queue.push(i)
queue.poll()
queue.pop()
print("", i, "轮入队 + 出队后 queue = ", queue.to_list())