Пример #1
0
 public static void Return(ListPoolList <T> list)
 {
     if (m_pool.Contains(list))
     {
         Debug.LogWarning("ListPool::Release called for a list that's already in the pool");
         return;
     }
     list.Clear();
     m_pool.Add(list);
 }
Пример #2
0
        public static ListPoolList <T> Get(ICollection <T> copyFrom = null)
        {
            ListPoolList <T> list = null;

            if (m_pool.Count > 0)
            {
                list = m_pool[0];
                m_pool.RemoveAt(0);
            }
            else
            {
                list = new ListPoolList <T>();
            }

            list.Clear(); // safety precaution

            if (copyFrom != null)
            {
                list.AddRange(copyFrom);
            }

            return(list);
        }