What C# Data Structure Supports The Following?
I need a C# data structure that works in the following way:
Define it with a static size
Adding new data to end of list
Oldest data falls off.
Random access of data elements
Example: If I define a structure of 5 elements and added the following
1,2,3,4,5,6,7,8
The data structure would look like the following:
4,5,6,7,8
I'm not sure which structure will work in this way. Vector? List? Stack?
The data structure supports a static size like an array and push data that
pushes off old data.
Stack/queue doesn't provide random access. List doesn't have a "push"
operation.
Perhaps a LinkedList and add custom operation for "push" that removes the
first element? LinkList random access is o(n) operation though.
No comments:
Post a Comment