我的目标是:
(capacity * ctypes.py_object)()
分配内存块,任何人都可以指出我正确的方向,我很困难。谢谢!
class deque:
capacity = 10
def __init__(self, size):
self._data = (capacity * ctypes.py_object)
self._size = 0
self._front = 0
def isEmpty(self):
return self._size == 0
def __len__(self):
return self._size
def __getitem__(self, index):
return self.list[index]
def addFront(self, item):
self.items.append(item)
def addRear(self, item):
self.items.insert(0, item)
def removeFront(self):
return self.items.pop()
def removeRear(self):
return self.items.pop(0)