Reputation: 7403
I'm just wondering what kind of queues are lists and dictionaries in C#. Whether they're FIFOs or LIFOs.
Upvotes: 2
Views: 4381
Reputation: 65431
In C#, if you want a LIFO (stack) use System.Collections.Generic.Stack, and if you want a FIFO (queue) use System.Collections.Generic.Queue
Upvotes: 11
Reputation: 17875
Dictionaries and lists aren't queues, and also FIFO and LIFO doesn't apply to C# lists and dictionaries. You can add/remove items anywhere in a list. You can also add/remove any entry in a dictionary. Not only at the beginning or at the end. Also, a dictionary isn't ordered so there is not even a concept of a beginning and an end.
Upvotes: 9
Reputation: 5392
Lists and dictionaries are containers that don't support a queue model, that is, they're neither LIFO nor FIFO. Put another way, you're not comparing apples with apples.
Upvotes: 21