Is list better than vector when we need to store “the last n items”?
Neither. Your collection has a fixed size and std::array is sufficient. The data structure you implement is called a ring buffer. To implement it you create an array and keep track of the offset of the current first element. When you add an element that would push an item out of the buffer – i.e. … Read more