storing instances in an array based python deque

17 Views Asked by At

I want to store instances in my deque, that I have created using array. here is the code I wrote for storing integers in my deque

class Adeque:
    def __init__(self):
        self.capacity = 2
        self.items = arr.array('i',[0 for x in range(self.capacity)])
        self.Nextfirst = 0
        self.Nextlast = 1
        self.currentsize = 0

how can I modify it, if my data type is now instances of some other class instead of integers ?

I tried creating an array with None as the items

class Adeque:
    def __init__(self):
        self.capacity = 2
        self.items = arr.array('O', [None for i in range(self.capacity)])
        self.Nextfirst = 0
        self.Nextlast = 1
        self.currentsize = 0

apparently, it does not work. it gives me some ValueError I do not want to store references and then work with them.

0

There are 0 best solutions below