Files
dingyuntian 9f20ef52d8 UI工具翻新
1. 增加UI工具
2. 增加设置页面
3. GameLoop更新
4. 导入ActionKit工具
2025-04-21 18:53:30 +08:00

45 lines
1.2 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System.Collections.Generic;
namespace AibisDream.Kit
{
public static class ListPool<T>
{
/// <summary>
/// 栈对象:存储多个List
/// </summary>
static readonly Stack<List<T>> ListStack = new(8);
/// <summary>
/// 出栈:获取某个List对象
/// </summary>
/// <returns></returns>
public static List<T> Get()
{
return ListStack.Count == 0 ? new List<T>(8) : ListStack.Pop();
}
/// <summary>
/// 入栈:将List对象添加到栈中
/// </summary>
/// <param name="toRelease"></param>
public static void Release(List<T> toRelease)
{
if (ListStack.Contains(toRelease))
{
throw new System.InvalidOperationException(
"重复回收 ListThe List is released even though it is in the pool");
}
toRelease.Clear();
ListStack.Push(toRelease);
}
}
public static class ListPoolExtensions
{
public static void Release2Pool<T>(this List<T> self)
{
ListPool<T>.Release(self);
}
}
}