[TASK] Initial commit with basic product setup

This commit is contained in:
2019-08-18 13:50:14 +02:00
commit 01a66a8e1f
2548 changed files with 167528 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
namespace Mapbox.Unity.MeshGeneration.Data
{
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ObjectPool<T>
{
private Queue<T> _objects;
private Func<T> _objectGenerator;
public ObjectPool(Func<T> objectGenerator)
{
if (objectGenerator == null) throw new ArgumentNullException("objectGenerator");
_objects = new Queue<T>();
_objectGenerator = objectGenerator;
}
public T GetObject()
{
if (_objects.Count > 0)
return _objects.Dequeue();
return _objectGenerator();
}
public void Put(T item)
{
_objects.Enqueue(item);
}
public void Clear()
{
_objects.Clear();
}
public IEnumerable<T> GetQueue()
{
return _objects;
}
}
}