コード例 #1
0
        /// <summary>
        /// Returns the next item to be taken from the back without removing it.
        /// </summary>
        /// <returns>The next item to be taken from the back.</returns>
        /// <exception cref="InvalidOperationException">No more items to be taken.</exception>
        public T Peek()
        {
            T   item;
            var index = Interlocked.Add(ref _indexEnqueue, 0);

            if (index < _capacity && index > 0 && _entries.TryGet(index, out item))
            {
                return(item);
            }
            throw new InvalidOperationException("Empty");
        }
コード例 #2
0
 /// <summary>
 /// Tries to retrieve the item at the specified index.
 /// </summary>
 /// <param name="index">The index.</param>
 /// <param name="value">The value.</param>
 /// <returns>
 ///   <c>true</c> if the item was retrieved; otherwise, <c>false</c>.
 /// </returns>
 /// <exception cref="ArgumentOutOfRangeException">index;index must be greater or equal to 0 and less than capacity</exception>
 public bool TryGet(int index, out T value)
 {
     return(_entries.TryGet(index, out value));
 }