+ 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

27th Nov 2019, 8:41 AM
sneeze
sneeze - avatar
6 Antworten
2nd Dec 2019, 8:50 PM
id001x
id001x - avatar
+ 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
2nd Dec 2019, 1:46 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 2
id001x he doesn't want to do enqueue deque it seems...
2nd Dec 2019, 9:22 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 2
Always welcome 🙃
2nd Dec 2019, 9:56 PM
id001x
id001x - avatar
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.
2nd Dec 2019, 2:04 PM
sneeze
sneeze - avatar
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
2nd Dec 2019, 9:50 PM
sneeze
sneeze - avatar