I'm working on a game in Yoyo Game Maker where I have items moving along conveyor belts. As the items only move in one direction, I thought it would make most sense to use a queue or queue-like data structure to store the items. However, to be able to render the items, I need to be able to read all of them at any point in the queue, not just the head or tail.
[[a] [b] [c] [d]]
|
V
a <- [[ ] [b] [c] [d]] <- e
|
V
[[b] [c] [d] [e]]
| | | |
V V V V
b c d e
I could simply use an array that manually moves all its values forward by one slot every turn (using a for loop), but somehow that seems inefficient, laggy, or at the very least, bad form. My programming instincts recoil at the thought of using such a system, anyway.
Is this a correct assumption to make? Is an array really the best way of implementing a structure like this? Should I even be worried about efficiency, or are the differences in this case negligible?
Some advice or examples (in any programming language) would be greatly appreciated.