From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../Assets/Scripts/XUtliPoolLib/DictionaryPool.cs | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Client/Assets/Scripts/XUtliPoolLib/DictionaryPool.cs (limited to 'Client/Assets/Scripts/XUtliPoolLib/DictionaryPool.cs') diff --git a/Client/Assets/Scripts/XUtliPoolLib/DictionaryPool.cs b/Client/Assets/Scripts/XUtliPoolLib/DictionaryPool.cs new file mode 100644 index 00000000..b5d01cd5 --- /dev/null +++ b/Client/Assets/Scripts/XUtliPoolLib/DictionaryPool.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; + +namespace XUtliPoolLib +{ + public class DictionaryPool + { + private static readonly ObjectPool> s_Pool = new ObjectPool>(new ObjectPool>.CreateObj(DictionaryPool.Create), delegate(Dictionary l) + { + l.Clear(); + }, delegate(Dictionary l) + { + l.Clear(); + }); + + public static Dictionary Create() + { + return new Dictionary(); + } + + public static Dictionary Get() + { + return DictionaryPool.s_Pool.Get(); + } + + public static void Release(Dictionary toRelease) + { + DictionaryPool.s_Pool.Release(toRelease); + } + } +} -- cgit v1.1-26-g67d0