Esempio n. 1
0
 def addTail(self, v):
     print("adding value", v, " at the end of the list")
     cell = Cell()
     cell.value = v
     cell.next = None
     if self.tail == None:
         cell.previous = None
         self.head = cell
         self.tail = cell
     else:
         cell.previous = self.tail
         self.tail.next = cell
         self.tail = cell
     self.dump()
Esempio n. 2
0
 def addHead(self, value):
     print("adding value", value, " at the head of the list")
     cell = Cell()
     cell.value = value
     cell.previous = None
     if self.head == None:
         cell.next = None
         self.head = cell
         self.tail = cell
     else:
         cell.next = self.head
         self.head.previous = cell
         self.head = cell
     self.dump()