Example #1
0
 def enqueue(self, item):
     oldlast = self.last
     self.last = Node(item, None)
     if self.is_empty():
         self.first = self.last
     else:
         oldlast.next = self.last
     self.n += 1
Example #2
0
 def push(self, item):
     oldfirst = self.first
     self.first = Node(item, oldfirst)
     self.n += 1