feat: ScrollQueue - added OnItemTrimmed event

This commit is contained in:
Drew Tingen
2020-05-07 18:16:54 -04:00
parent f9dccd30e5
commit 2ad9adf86c
3 changed files with 50 additions and 0 deletions

View File

@@ -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