Class ObservableLimitedQueue<T>
- Namespace
- Loehnert.Utility.Collections
- Assembly
- Loehnert.Utility.dll
Represents an observable, thread-safe Queue<T> with a flexible size limited.
public class ObservableLimitedQueue<T> : IEnumerable<T>, IEnumerable, INotifyCollectionChanged, INotifyPropertyChanged
Type Parameters
T
Type for the queue.
- Inheritance
-
ObservableLimitedQueue<T>
- Implements
-
IEnumerable<T>
- Inherited Members
- Extension Methods
Constructors
ObservableLimitedQueue(int)
Initializes a new instance of the ObservableLimitedQueue<T> class.
public ObservableLimitedQueue(int queueSizeLimit)
Parameters
queueSizeLimit
intSize limit (zero or greater) for the queue, sets the MaximumNumberOfItems property.
Properties
MaximumNumberOfItems
Gets or sets the size of the queue.
public int MaximumNumberOfItems { get; set; }
Property Value
Remarks
If Enqueue(T) adds an object and the number of queued items is greater than MaximumNumberOfItems, the oldest item will be removed. If this property is set and the queue contains more items than the new value, items are removed from the beginning of the queue until the queue contains more than MaximumNumberOfItems items.
Methods
Clear()
Removes all objects from the queue/>.
public void Clear()
Dequeue()
Attempts to remove and return the object at the beginning of the queue.
public T Dequeue()
Returns
- T
The removed item.
Enqueue(T)
Adds an item to the end of the queue and removes an item from the beginning, when the queue contains more than MaximumNumberOfItems items.
public void Enqueue(T item)
Parameters
item
TThe item to add.
GetEnumerator()
Get an enumerator that iterates through the queue.
public IEnumerator<T> GetEnumerator()
Returns
- IEnumerator<T>
An IEnumerator<T> object that can be used to iterate through the collection.
Events
CollectionChanged
Occurs when the queue changed.
public event NotifyCollectionChangedEventHandler CollectionChanged
Event Type
PropertyChanged
Occurs when a property of the queued items changed.
public event PropertyChangedEventHandler PropertyChanged