Generation

generate functionSat, 12 Nov 2022

functional queue

public class Queue<T> { private readonly List<T> _list = new List<T>(); public void Enqueue(T item) { _list.Insert(0, item); } public T Dequeue() { var ret = Peek(); _list.RemoveAt(0); return ret; } public T Peek() { return _list[0]; } } var q = new Queue<int>(); q.Enqueue(1); q.Enqueue(2); q.Enqueue(3); q.Dequeue(); q.Peek();

Questions about programming?Chat with your personal AI assistant