class PlaneQueue:
def __init__(self):
self.head = None
self.tail = None
def push(self, plane_node):
"""Pushes a plane node onto the queue.
Args:
plane_node: The plane node to push.
Returns:
None.
"""
# If the queue is empty, set the new node as the head and tail.
if self.head is None:
self.head = plane_node
self.tail = plane_node
return
# Set the new node as the tail and the previous tail's next node.
self.tail.next = plane_node
self.tail = plane_node
def pop(self):
"""Pops a plane node from the front of the queue.
Returns:
The plane node that was popped.
"""
# If the queue is empty, return None.
if self.head is None:
return None
# Get the plane node at the front of the queue.
plane_node = self.head
# Set the head to the next node.
self.head = self.head.next
# If the head is now None, set the tail to None as well.
if self.head is None:
self.tail = None
return plane_node