17 using System.Collections;
18 using System.Collections.Generic;
27 private readonly
int _size;
28 private readonly Queue<T> _queue;
29 private readonly HashSet<T> _hash;
38 _queue =
new Queue<T>(size);
39 _hash =
new HashSet<T>();
45 public bool Add(T item)
50 if (_queue.Count > _size)
53 _hash.Remove(_queue.Dequeue());
65 return _queue.TryPeek(out item);
73 var item = _queue.Dequeue();
83 return _hash.Contains(item);
95 return _queue.GetEnumerator();
105 IEnumerator IEnumerable.GetEnumerator()