summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XUtliPoolLib/DictionaryPool.cs
blob: b5d01cd516bb66b26648e31d6f09c8a4b031b0d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
using System;
using System.Collections.Generic;

namespace XUtliPoolLib
{
	public class DictionaryPool<K, V>
	{
		private static readonly ObjectPool<Dictionary<K, V>> s_Pool = new ObjectPool<Dictionary<K, V>>(new ObjectPool<Dictionary<K, V>>.CreateObj(DictionaryPool<K, V>.Create), delegate(Dictionary<K, V> l)
		{
			l.Clear();
		}, delegate(Dictionary<K, V> l)
		{
			l.Clear();
		});

		public static Dictionary<K, V> Create()
		{
			return new Dictionary<K, V>();
		}

		public static Dictionary<K, V> Get()
		{
			return DictionaryPool<K, V>.s_Pool.Get();
		}

		public static void Release(Dictionary<K, V> toRelease)
		{
			DictionaryPool<K, V>.s_Pool.Release(toRelease);
		}
	}
}