In C# I use a Queue collection. I can easily Enqueue or Dequeue. Okay, now I would like to insert something in the middle of the queue or at the beginning of the queue. I don't find any method to do such thing. What do you recommend as the alternate collection?
What you're looking for is a LinkedList<T>
. You can add to the beginning, middle (using AddBefore or AddAfter), or end of the list.
This is advantagous over using a List<T>
because you can then use RemoveFirst or RemoveLast to have it imitate more closely a Queue or a Stack.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With