.net FIFO "Queue" combined with the last known topic
Look for any existing FIFO queue that also handles theme-based overrides as mentioned below.
struct QueueItem { string Topic; .... other data }
if the queue has items added in order
q.Add( new QueueItem() { topic = A, ... } ); //1
q.Add( new QueueItem() { topic = B, ... } ); //2
q.Add( new QueueItem() { topic = C, ... } ); //3
q.Add( new QueueItem() { topic = A, ... } ); //4
q.Add( new QueueItem() { topic = B, ... } ); //5
When searching, the order should be # 4 Topic A - skipping # 1 # 5 Topic B - skipping # 2 # 3 Topic C
and etc.
NOTE. The order in which elements / themes are added / processed is important given the above rule
I wonder if this is a known scenario and there may be a pre-existing implementation already
source to share
What you are looking for is a priority queue. Your requirement is slightly different in that it uses letters instead of integers instead of precedence, but the concept is the same. See. Replies priority queues, C # and foremost priorities in .Net
source to share
For a successful implementation of safe thread-safe validation, check out the ConcurrentQueue <T> built into the framework since v4.
Having said that, the behavior you are asking for is not strictly a queue, it is rather a list where Add () is overridden to add or replace an equivalent existing element. So the question remains: do you want a FIFO queue or add / replace list?
source to share