using System.Collections.Generic; public class GameObjectPool where T : class { short count; public delegate T Func(); Func create_fn; Queue objects; public GameObjectPool(short count, Func fn) { this.count = count; this.create_fn = fn; this.objects = new Queue(this.count); allocate(); } void allocate() { for (int i = 0; i < this.count; i++) { this.objects.Enqueue(this.create_fn()); } } public T pop() {//dequeue 꺼내는 부분 if (this.objects.Count <= 0) { allocate(); } return this.objects.Dequeue(); } public void push(T obj) {//enqueue 쌓는부분 this.objects.Enqueue(obj); } }