tomdodd4598

Untitled

May 14th, 2021
744
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import import_ipynb
  2.  
  3. from item import *
  4.  
  5. def insert_item(start, value, method_container):
  6.     print("Creating item: {}".format(value))
  7.     item = Item(value, method_container)
  8.     current = start
  9.     previous = None
  10.    
  11.     while (current != None and not item.insert_before(current)):
  12.         previous = current
  13.         current = current._next
  14.    
  15.     if previous == None:
  16.         start = item
  17.     else:
  18.         previous._next = item
  19.    
  20.     item._next = current
  21.    
  22.     return start
  23.  
  24. def remove_item(start, value):
  25.     current = start
  26.     previous = None
  27.    
  28.     while current != None and not current.value_equals(value):
  29.         previous = current
  30.         current = current._next
  31.    
  32.     if current == None:
  33.         print("Item {} does not exist!".format(value))
  34.     else:
  35.         if previous == None:
  36.             start = current._next
  37.         else:
  38.             previous._next = current._next
  39.        
  40.         print("Removed item: {}".format(value))
  41.    
  42.     return start
  43.  
  44. def remove_all(start):
  45.     return None
  46.  
  47. def print_list(start):
  48.     while start != None:
  49.         start = start.print_get_next()
  50.  
  51. def print_iterator(start):
  52.     if start == None:
  53.         return
  54.     for item in start:
  55.         item.print_get_next()
  56.  
  57. def print_array(start):
  58.     if start == None:
  59.         return
  60.     for i in range(len(start)):
  61.         start[i].print_get_next()
RAW Paste Data