Esempio n. 1
0
        private void RemoveLast()
        {
            Debug.Assert(!IsEmpty);

            _count--;
            _head[--_headCount] = default(T);

            // To maintain invariants, we need to make sure the head block isn't empty unless
            // the entire block list is empty.
            if (_headCount == 0)
            {
                if (_tail.IsEmpty)
                {
                    // The entire block list is empty, so revert to the initial state.
                    Reset();
                }
                else
                {
                    // Throw away the current head block and pretend we've just finished filling the last block.
                    _capacity -= HeadCapacity;
                    _head      = _tail.RemoveLast();
                    _headCount = _head.Length;
                }
                Debug.Assert(IsFull);
            }
        }