Ok, so I know there exist some really good threads about the cost of different operations on the Collection
interface. When to use LinkedList<> over ArrayList<>? gives a great overview of the difference between ArrayList
and LinkedList
. But after reading that thread I am still unsure of one thing:
Is the algorithmic runtime of removeFirst()/pollFirst()
and removeLast()/pollLast()
O(1) or do i have to use an Iterator
to achieve this?