Files
HellionChat/ChatTwo/Util/Lender.cs
T
Infi 3cfe65d2d4 - More ImRaii
- Cleanup
- Spanish, French, Dutch, Chinese loc update
2024-11-21 11:58:22 +01:00

27 lines
428 B
C#
Executable File

namespace ChatTwo.Util;
internal class Lender<T>
{
private readonly Func<T> Ctor;
private readonly List<T> Items = [];
private int Counter;
internal Lender(Func<T> ctor)
{
Ctor = ctor;
}
internal void ResetCounter()
{
Counter = 0;
}
internal T Borrow()
{
if (Items.Count <= Counter)
Items.Add(Ctor());
return Items[Counter++];
}
}