Efficient way to implement an indexed queue (where elements can be retrieved by index in O(1) time)?

Viewed 4960

Accessing items by index using ElementAt is obviously not a reasonable choice, as per .NET queue ElementAt performance.

Is there an alternative generic data structure that would be appropriate for this requirement?

My queue has a fixed capacity.

As per MSDN entry on the Queue class, "This class implements a queue as a circular array", yet it doesn't seem to expose any kind of indexing property.

Update: I have found C5's implementation of a CircularQueue. It seems to fit the bill, but I would prefer not to have to import another external library if possible.

2 Answers
Related