I’ve been searching for this to no avail, perhaps it’s not really a “thing”.
Is there a specific name given to stacks that are limited in size where it does not matter if values are dropped?
This comes up most naturally in page history situations. Browser history on per-tab basis can be thought of as a stack. When I go to a new website, I push something on. When I hit the back button, I pop something off and into a separate stack in case I hit the forward button.
However, you could conceivably limit the size of this stack. Maybe it will only remember the last twenty websites I have visited in that tab. When the stack reaches size 20, new items will be pushed with the oldest items being popped.
Is this behavior, of a push causing a corresponding pop on the other end, after a certain size threshold, noteworthy and useful in any way other than as a curiosity? If it is, what is this kind of structure classified as and could you provide additional use cases for it?
if you implement the stack with FixedSizeCircularBuffer you can do this. So essentially, anything new will be dropped as long as your buffer is full.
Please look at Circular Buffer in which you can do what you are asking, and Circular buffer can be used to implement both stack and queue.