I'm just wondering what kind of queues are lists and dictionaries in C#. Whether they're FIFOs or LIFOs.
+18
A:
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.
Eric Smith
2009-08-12 12:31:52
Put another way, you haven't even Googled (or Binged)
Jeff Yates
2009-08-12 12:48:38
+7
A:
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.
Meta-Knight
2009-08-12 12:32:26
To extend this further, the documentation for Dictionary<TKey, TValue> actually states that the items are unordered and can be returned in any order when enumerating.
KeeperOfTheSoul
2009-08-12 12:34:58
+9
A:
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
Patrick McDonald
2009-08-12 12:36:47