3cfe65d2d4
- Cleanup - Spanish, French, Dutch, Chinese loc update
27 lines
428 B
C#
Executable File
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++];
|
|
}
|
|
}
|