I have a problem where I need to use a type of collection in my android application. The collection should insert items at the top and will remove from the top too but also clear all the bottom most items from it.
For example, if I have following in the collection.
1 | 2 | 3 | 4 | 5
I insert “6”.
1 | 2 | 3 | 4 | 5 | 6
I remove “6”
Empty
I insert “7”
7
And I insert “8”
7 | 8
LinkedListhas all needed methods enabling you to add item to front or end of list. You can remove all withclear().