The Perl version is also very fast - not as fast as C, but much easier to write!
No, it's practically exactly the same, op for op.
So to implement a FIFO queue in Perl, just push new entries onto the bottom of the Perl array and shift out "oldest" entries from the top.
A circular buffer is a queue (FIFO), but a queue is not necessarily a circular buffer. You didn't provide any indication as to whether the code you posted is a suitable solution for the OP or not.
It turns out the code you (and I) posted does exhibit the same characteristics as a circular buffer. See my reply.
The Perl array also can implement essentially the equivalent of a 'C' doubly linked list. [...] But in Perl you can use splice()
If you can use splice, you don't have a linked list. Linked lists take O(1) to remove a previously found element. splice takes O(N).
In reply to Re^2: Circular buffer
by ikegami
in thread Circular buffer
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |