46

Is there a standard collection in .NET that implements a FIFO stack?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Rella
  • 65,003
  • 109
  • 363
  • 636

3 Answers3

75

FIFO means first-in-first-out. The data structure you're looking for is called a Queue.

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
Dave Markle
  • 95,573
  • 20
  • 147
  • 170
  • 5
    yes, or asker meant named pipes: http://en.wikipedia.org/wiki/Named_pipe - named pipe (also known as a FIFO for its behavior) – Andrey Jun 03 '10 at 13:22
23

FIFO means first in first out. This is as opposed to LIFO (or FILO as lucero pointed out). which is last in first out.

A link comparing queues, stacks, and hashtables.

You want to use a queue object for FIFO operations:

http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=66

MSDN link on queues

And a stack is used for LIFO operations: Stack Link

kemiller2002
  • 113,795
  • 27
  • 197
  • 251
21

Are you looking for the Queue<T> class?

NoDataDumpNoContribution
  • 10,591
  • 9
  • 64
  • 104
LukeH
  • 263,068
  • 57
  • 365
  • 409