Esempio n. 1
0
 def pop(self):
     if self._head is None:
         raise LinkedListUnderflow("in pop of LDList")
     e = self._head.elem
     self._head = self._head.next
     if self._head:
         self._head.prev = None
     return e
Esempio n. 2
0
 def pop(self):  # pop out head element
     if self._rear is None:
         raise LinkedListUnderflow("in pop of CLList")
     p = self._rear.next
     if self._rear is p:
         self._rear = None
     else:
         self._rear.next = p.next
     return p.elem
Esempio n. 3
0
 def pop_last(self):
     if self._head is None:
         raise LinkedListUnderflow("in pop_last of LDList")
     e = self._rear.elem
     self._rear = self._rear.prev
     if self._rear is None:
         self._head = None  # it is empty now
     else:
         self._rear.next = None
     return e
 def pop(self):
     if self._head is None:
         raise LinkedListUnderflow("in pop of LDList")
     e = self._head.elem
     self._head = self._head.next
     if self._head is None:
         self._rear = None  # it is empty now
     else:
         self._head.prev = None
     return e
 def pop_last(self):
     if self._head is None:  # empty list
         raise LinkedListUnderflow("in pop_last")
     p = self._head
     if p.next is None:  # list with only one element
         e = p.elem
         self._head = None
         return e
     while p.next.next:  # till p.next be last node
         p = p.next
     e = p.next.elem
     p.next = None
     return e
 def pop(self):
     if self._head is None:
         raise LinkedListUnderflow("in pop")
     e = self._head.elem
     self._head = self._head.next
     return e