'How do I join the rest of the array after having removed an element in a specific index?
How do I join the rest of the array after having removed an element in a specific index? I want the "holes" None to disappear. The constructor:
def __init__(self, capacity=8):
self.__data = [None] * capacity
self.__front = 0
self.__size = 0
The function with problems:
def abandon_queue(self, index):
if self.is_empty():
raise ValueError('A fila está vazia! Não pode remover nenhum cliente')
while int(index) > 8 or int(index) < 0:
raise ValueError("Está fora da capacidade da fila")
while 0 <= int(index) <= 8:
remove = self.__data[int(index)]
self.__data[int(index)] = None
self.__front = (self.__front + 1) % len(self.__data)
self.__size -= 1
return remove
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
