I need a data structure, a fixed LIFO size, the last in the first. Is it already there?
Edit: Sorry, I want LIFO, not FIFO.
I checked http://docs.python.org/library/queue.html , it already provides LIFO, the only thing I want to achieve is to automatically abandon the oldest one.
For example) LIFO size 5 with elements: 1 2 3 4 5
After 6 enters, 1 should be discarded, it becomes:
2 3 4 5 6
How can I do that?
source
share