コード例 #1
0
        /// <summary>
        /// this is a dirtish trick to be able to use the index operastor
        /// before adding the elements through the Add functions
        /// </summary>
        /// <typeparam name="U"></typeparam>
        /// <param name="initialSize"></param>
        /// <returns></returns>
        public static FasterList <T> PreFill <U>(int initialSize) where U : T, new()
        {
            var list = new FasterList <T>(initialSize);

            for (int i = 0; i < initialSize; i++)
            {
                list.Add(new U());
            }

            list._count = 0;

            return(list);
        }
コード例 #2
0
        public void DequeueAllInto(FasterList <T> list)
        {
            LockQ.EnterWriteLock();
            try
            {
                while (m_Queue.Count > 0)
                {
                    list.Add(m_Queue.Dequeue());
                }
            }

            finally
            {
                LockQ.ExitWriteLock();
            }
        }
コード例 #3
0
 public void DequeueInto(FasterList <T> list, int count)
 {
     _lockQ.EnterWriteLock();
     try
     {
         int originalSize = _queue.Count;
         while (_queue.Count > 0 && originalSize - _queue.Count < count)
         {
             list.Add(_queue.Dequeue());
         }
     }
     finally
     {
         _lockQ.ExitWriteLock();
     }
 }
コード例 #4
0
        public FasterList <T> DequeueAll()
        {
            FasterList <T> returnList = new FasterList <T>(_queue.Count);

            _lockQ.EnterWriteLock();
            try
            {
                while (_queue.Count > 0)
                {
                    returnList.Add(_queue.Dequeue());
                }

                return(returnList);
            }
            finally
            {
                _lockQ.ExitWriteLock();
            }
        }
コード例 #5
0
        public FasterList <U> DequeueAllAs <U>() where U : class
        {
            FasterList <U> returnList = new FasterList <U>();

            _lockQ.EnterWriteLock();
            try
            {
                while (_queue.Count > 0)
                {
                    returnList.Add(_queue.Dequeue() as U);
                }

                return(returnList);
            }
            finally
            {
                _lockQ.ExitWriteLock();
            }
        }