EQueue.cs 562 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. namespace Model
  4. {
  5. public class EQueue<T>: IEnumerable
  6. {
  7. private readonly LinkedList<T> list = new LinkedList<T>();
  8. public void Enqueue(T t)
  9. {
  10. this.list.AddLast(t);
  11. }
  12. public T Dequeue()
  13. {
  14. T t = this.list.First.Value;
  15. this.list.RemoveFirst();
  16. return t;
  17. }
  18. public int Count
  19. {
  20. get
  21. {
  22. return this.list.Count;
  23. }
  24. }
  25. public IEnumerator GetEnumerator()
  26. {
  27. return this.list.GetEnumerator();
  28. }
  29. public void Clear()
  30. {
  31. this.list.Clear();
  32. }
  33. }
  34. }