Class ThreadSafeLimitedHistory<T>
Limited size history which automatically ejects old elements when more than N elements added. New elements added to top of the history (as most recent) and will be returned first while enumeration. Elements can't be directly removed from history one by one, but you can Clear() whole history.
Inheritance
System.Object
ThreadSafeLimitedHistory<T>
Implements
System.Collections.Generic.IEnumerable<T>
System.Collections.IEnumerable
Namespace: Eco.Core.Utils
Assembly: Eco.Core.dll
Syntax
public class ThreadSafeLimitedHistory<T> : Object, IEnumerable<T>, IEnumerable, ISnapshotable<T>, ISnapshotable
Type Parameters
Name | Description |
---|---|
T |
Constructors
ThreadSafeLimitedHistory(Int32)
Declaration
public ThreadSafeLimitedHistory(int size)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | size |
Properties
Count
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Snapshot
Declaration
public ICollection<T> Snapshot { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.ICollection<T> |
Methods
Add(T)
Adds new element
and ejects any elements which is behind Eco.Core.Utils.ThreadSafeLimitedHistory`1.size.
Declaration
public void Add(T element)
Parameters
Type | Name | Description |
---|---|---|
T | element |
Clear()
Declaration
public void Clear()
GetEnumerator()
Returns elements in order they was added. If you need to get most recent elements first then you need to use Reverse function.
Declaration
public IEnumerator<T> GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerator<T> |
Explicit Interface Implementations
ISnapshotable.Snapshot
Declaration
ICollection ISnapshotable.Snapshot { get; }
Returns
Type | Description |
---|---|
System.Collections.ICollection |
Implements
System.Collections.Generic.IEnumerable<>
System.Collections.IEnumerable