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

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

		public static List<T> Get()
		{
			return ListPool<T>.s_Pool.Get();
		}

		public static void Release(List<T> toRelease)
		{
			ListPool<T>.s_Pool.Release(toRelease);
		}
	}
}