示例#1
0
        public void ReturnItem(T item)
        {
            PooledItem <T> pooledItem = poolList.Find(i => i.item.Equals(item));

            if (pooledItem != null)
            {
                pooledItem.isUsed = false;
            }
        }
示例#2
0
        public T GetItem()
        {
            if (poolList.Count > 0)
            {
                PooledItem <T> item = poolList.Find(i => i.isUsed == false);
                if (item != null)
                {
                    item.isUsed = true;
                    return(item.item);
                }
            }

            PooledItem <T> pooledItem = new PooledItem <T>();

            pooledItem.isUsed = true;
            pooledItem.item   = CreatePooledItem();
            poolList.Add(pooledItem);
            return(pooledItem.item);
        }