Exemple #1
0
        public void AddFirst(T item)
        {
            lock (SyncRoot)
            {
                if (capacity == buffer.Count)
                {
                    var remItem = buffer.RemoveLast();
                    CollectionChanged?.Invoke(NotifyCollectionChangedEventArgs <T> .Remove(remItem, capacity - 1));
                }

                buffer.AddFirst(item);
                CollectionChanged?.Invoke(NotifyCollectionChangedEventArgs <T> .Add(item, 0));
            }
        }
Exemple #2
0
 public T RemoveLast()
 {
     lock (SyncRoot)
     {
         var index = buffer.Count - 1;
         var item  = buffer.RemoveLast();
         CollectionChanged?.Invoke(NotifyCollectionChangedEventArgs <T> .Remove(item, index));
         return(item);
     }
 }