Is there any case when a Stack or a Queue implementation with ArrayList gives better, faster performance then a LinkedList implemented in Java? -


in question read following:

if you're doing comparatively few operations, ie less 1000 or enqueue/dequeues in total, array faster because contiguous in memory.

my question is: how caching arraylist works in java? there cases, when arraylist implemented queue or stack perform better linkedlist implemented in java?

hen arraylist implemented queue or stack perform better linkedlist implemented in java?

when queue empty or 1 element, arraylist faster , creates less garbage (ie none)

if have fast consumer, consumer ever producer produces produces it. means there typically 0 or 1 elements in queue. under these conditions arraylist faster doesn't create objects or produce garbage.

btw arraydeque better choice because performs if there more 1 element.

how caching arraylist works in java?

there nothing special way cpu caches accesses arraylist.


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -