I have written an algorithm that has a lot of appending and removing items to an end of a data structure (basically last in first out).
Now for some reason, when I do this operation with ArrayList
, it is much faster than a LinkedList
, even through ArrayList requires the overhead of relocations. It's not even slightly faster. It's faster by miles!
Why is this?