mirror of
https://github.com/ICDSystems/ICD.Common.Utils.git
synced 2026-02-15 20:54:58 +00:00
feat: ScrollQueue - added OnItemTrimmed event
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using ICD.Common.Properties;
|
||||
using ICD.Common.Utils.EventArguments;
|
||||
using ICD.Common.Utils.Extensions;
|
||||
|
||||
namespace ICD.Common.Utils.Collections
|
||||
{
|
||||
@@ -15,6 +17,8 @@ namespace ICD.Common.Utils.Collections
|
||||
private readonly LinkedList<TContents> m_Collection;
|
||||
private int m_MaxSize;
|
||||
|
||||
public event EventHandler<GenericEventArgs<TContents>> OnItemTrimmed;
|
||||
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
@@ -141,7 +145,11 @@ namespace ICD.Common.Utils.Collections
|
||||
private void Trim()
|
||||
{
|
||||
while (Count > MaxSize)
|
||||
{
|
||||
TContents removed = m_Collection.First.Value;
|
||||
m_Collection.RemoveFirst();
|
||||
OnItemTrimmed.Raise(this, new GenericEventArgs<TContents>(removed));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user