3 ms·
That's almost true under the assumption that you are using the most elementary implementation possible with only a single array (insert at end of array, realloc
by robmccoll 12y ago
That's almost true under the assumption that you are using the most elementary implementation possible with only a single array (insert at end of array, reallocate as needed to increase array length, copy elements down during dequeue, etc.) - you would still be avoiding the garbage collector relocating your array elements and generally get better performance due to nice alignment within cache lines in memory. With a more advanced implementation using multiple arrays, you can do even better (basically a blocked linked list), and you can cache the blocks as you dequeue and free up blocks to avoid hitting the memory allocator more than necessary. If you want to get really crazy with it, you can start doing blocks of multiple sizes that grow and shrink dynamically with the usage behavior of the list, but at that point what you have done is implement a memory allocator.