Beispiel #1
0
 /// <summary>
 /// Конструктор
 /// </summary>
 /// <param name="queue">Очередь</param>
 public QueueEnumerator(FixedCapacityIndexedQueue <TEnumerator> queue)
 {
     _queue        = queue;
     _currentIndex = -1;
     _valuesCount  = _queue.Count;
     _version      = _queue._version;
 }
Beispiel #2
0
        /// <summary>
        /// Извлечение из очереди
        /// </summary>
        /// <param name="index">Индекс</param>
        /// <returns></returns>
        public T Dequeue(int index)
        {
            if (index < 0 || index >= Count)
            {
                throw new ArgumentOutOfRangeException("The index of element to remove must be within the number of elements");
            }

            T t = _array[index];

            for (int i = index + 1; i < Count; i++)
            {
                _array[i - 1] = _array[i];
            }
            FixedCapacityIndexedQueue <T> fixedCapacityIndexedQueue = this;

            fixedCapacityIndexedQueue.Count = fixedCapacityIndexedQueue.Count - 1;
            _array[Count] = default(T);
            FixedCapacityIndexedQueue <T> fixedCapacityIndexedQueue1 = this;

            fixedCapacityIndexedQueue1._spaceLeft = fixedCapacityIndexedQueue1._spaceLeft + 1;
            FixedCapacityIndexedQueue <T> fixedCapacityIndexedQueue2 = this;

            fixedCapacityIndexedQueue2._version = fixedCapacityIndexedQueue2._version + 1;
            return(t);
        }
Beispiel #3
0
        /// <summary>
        /// Добавление в очередь
        /// </summary>
        /// <param name="obj">Объект</param>
        /// <returns></returns>
        public bool Enqueue(T obj)
        {
            bool flag;

            if (_spaceLeft != 0)
            {
                T[] tArray = _array;
                FixedCapacityIndexedQueue <T> fixedCapacityIndexedQueue = this;
                int num  = fixedCapacityIndexedQueue.Count;
                int num1 = num;
                fixedCapacityIndexedQueue.Count = num + 1;
                tArray[num1] = obj;
                FixedCapacityIndexedQueue <T> fixedCapacityIndexedQueue1 = this;
                fixedCapacityIndexedQueue1._spaceLeft = fixedCapacityIndexedQueue1._spaceLeft - 1;
                FixedCapacityIndexedQueue <T> fixedCapacityIndexedQueue2 = this;
                fixedCapacityIndexedQueue2._version = fixedCapacityIndexedQueue2._version + 1;
                flag = true;
            }
            else
            {
                flag = false;
            }
            return(flag);
        }