tags:

views:

285

answers:

4

Hello, in Java, there's a class called Deque, and i would like to find something similar to this in .NET (C#).

The reason i need this, is because i need to peek the last item in the collection, and then dequeue the first one in the collection.

Thanks, AJ Ravindiran.

A: 

Check out .NET's Queue collection. Sounds exactly like what you're looking for.

WayneC
By last item, I meant the last item added. Queue.Peek() only foresees the item that would be dequeued next.
AJ Ravindiran
Deque = double ended queue
dan
+1  A: 

List should do that for you:

var l = new List<int>();
var last = l[l.Count - 1];
l.RemoveAt(0);
Mark
+3  A: 

PowerCollections has a Deque class (and a proven pedigree).

itowlson
+1 for actually providing a solution.
Matt Olenik
A: 

Something like this was touched on in another SO question .

The popular answer seemed to be settling with a linked list, and Eric Lippert suggested his own Deque implementation.

So I guess the short answer is no, there is no such strict data structure built-in in .NET

HTH.

BranTheMan