Ejemplo n.º 1
0
        /// <summary>
        ///     Adds the specified item. May overwrite an existing item.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <returns>Returns the position where the item was added.</returns>
        public int Add(T item)
        {
            var index = Interlocked.Increment(ref _index) & (Capacity - 1);

            _entries.SetInternal(index, item, out _);
            return(index);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds the specified item. May overwrite an existing item.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <returns>Returns the position where the item was added.</returns>
        public int Add(T item)
        {
            var  index = Interlocked.Increment(ref _index) & (_capacity - 1);
            bool isNew;

            _entries.SetInternal(index, item, out isNew);
            return(index);
        }