Advertisement
carisa

Untitled

Mar 22nd, 2020
1,413
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class ListDeque:
  2.  
  3.     def __init__(self):
  4.         self.__items = []
  5.  
  6.     def __size__(self):
  7.         return len(self.__items)
  8.  
  9.     def is_empty(self):
  10.         return self.__items == []
  11.  
  12.     def add_first(self, item):
  13.         self.__items.insert(0, item)
  14.  
  15.     def add_last(self, item):
  16.         self.__items.append(item)
  17.  
  18.     def get_first(self):
  19.         return self.__items[0]
  20.  
  21.     def get_last(self):
  22.         return self.__items[-1]
  23.  
  24.     def remove_first(self):
  25.         return self.__items.pop(0)
  26.  
  27.     def remove_last(self):
  28.         return self.__items.pop()
  29.  
  30.     def clear(self):
  31.         return self.__items.clear()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement