To save the installation of O (1) (with the oldest element removed for 100) and search for O (1), you need a class that implements IDictionary and saves an internal ordered list. If memory is more worrying, a BST implementation, for example, might be more appropriate SortedList. In any case, your class will contain both T[], and Dictionary<T,K>(or SortedList<T,K>). Make your own ring buffer indexing (easy) and save both collections in add, delete, etc. methods. You will have:
- O (1) enqueue (back)
- O (n), which violates the order of addition (since you must update the array); you'll probably never need it anyway
- O (1) dequeue (front)
- O (1) or O (log n) keyword search
IDictionary<T,K> IDictionary, , .
: ? , , :
- ( , , - )
- :
Count , this[key]. , , , . , . - : , , .
, , , . , O (1) .