summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XUtliPoolLib/HashPool.cs
blob: 2c9f5a1bb8b27ca8d86eca6ba92f28b4998d2f7a (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 HashPool<T>
	{
		private static readonly ObjectPool<HashSet<T>> s_Pool = new ObjectPool<HashSet<T>>(new ObjectPool<HashSet<T>>.CreateObj(HashPool<T>.Create), delegate(HashSet<T> l)
		{
			l.Clear();
		}, delegate(HashSet<T> l)
		{
			l.Clear();
		});

		public static HashSet<T> Create()
		{
			return new HashSet<T>();
		}

		public static HashSet<T> Get()
		{
			return HashPool<T>.s_Pool.Get();
		}

		public static void Release(HashSet<T> toRelease)
		{
			HashPool<T>.s_Pool.Release(toRelease);
		}
	}
}