Beispiel #1
0
 def add(self, item):
     """Adds item to the rear of the queue."""
     newNode = Node(item, None)
     if self.is_empty():
         self._front = newNode
     else:
         self._rear.next = newNode
     self._rear = newNode
     self._size += 1
 def push(self, item):
     """Adds item to the top of the stack."""
     self._items = Node(item, self._items)
     self._size += 1