I have a question but I don’t know how to search about it, so wanted to ask you.
It may sound simple but I’m a kind of a newbie.
I’m coding in C++. I have 20 values in an array. I do some work on them and after the calculation, I need to add a new value to these 20 values and need to delete the oldest variable. A kind of updating the array with new values.
For example:
My previous values : a,b,c,d, …. t
My current values : b,c,d,e …. u
This process will go on under a loop as long as the condition is not satisfied.
So, my question is: Is there any specific structure or method to perform this task or do I have to handle this work manually ? (Actually, I could do it by writing an impractical method which could be enough for me but I don’t think there might not be a dedicated stack structure for this work)
Thanks in advance.
Use
std::queueorstd::deque(difference that queue is FIFO(first in first out) when deque can remove elements from both sides):