+ 2
a queue with fixed size
Is there a queue with fixed size. I like to put items in a list, if the list is bigger than 10 elements the first in the list should be delete automatically. I have seen queue. But this does not seem to have added value. Of course I can do it imyself Enqueue items and if the list gets bigger than 10 items dequeue one. but it look like I also could use a list, insert(0,item) and remove[count]. Can I maximize the number of elements in a queue ? Is there a reason to use a queue instead of a list
6 Antworten
+ 2
I hope it help you ...
https://code.sololearn.com/ccmFHPJIJ06c/?ref=app
+ 2
So many questions..... Let's focus one by one.... Queue is dynamic in size... If you have fixed size, opt for array instead of queue
+ 2
id001x he doesn't want to do enqueue deque it seems...
+ 2
Always welcome 🙃
0
I could use an array. But how to keep the right order or shift the array. When a new item is added the oldest element should be deleted / overwritten.
0
Thanks id001x. You did it again.
This is exactly what I wanted.
A queue that grows till a certain specified size. If the certain size is met it should removes the oldest element.
Sorry if I have not been clear in the beginning