Ejemplo n.º 1
0
        void ICollection.CopyTo(Array array, int index)
        {
            if (array == null)
            {
                Thrower.ThrowArgumentNullException(ExceptionArgument.array);
            }

            int length = array.Length;

            if ((index < 0) || (index > length))
            {
                Thrower.ThrowArgumentOutOfRangeException(ExceptionArgument.arrayIndex, ExceptionResource.ArgumentOutOfRange_Index);
            }

            int num2 = (length - index);

            if (num2 < _size)
            {
                Thrower.ThrowArgumentException(ExceptionResource.Argument_InvalidOfLen);
            }

            // If the head is above tha tail we need to do two copies. The first copy will get
            // the elements between the head and the end of the queue and the second copy will get
            // the elements between the top of the queue and the tail.
            if (_tail < _head)
            {
                int num3 = _array.Length - _head;
                Array.Copy(_array, _head, array, index, num3);
                Array.Copy(_array, 0, array, index + num3, _tail);
            }
            else
            {
                Array.Copy(_array, _head, array, index, _head - _tail);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Specifies that each entry should be automatically removed from the
 /// cache once a fixed duration has elapsed after entry's creation, the
 /// most recent replacement of its value, or its last access.
 /// </summary>
 /// <param name="duration">
 /// The length of time after an entry is last
 /// accessed that it should be automatically removed.</param>
 /// <returns>
 /// This cache builder instance with the expire after nanos
 /// set to the specified values.</returns>
 /// <exception cref="ArgumentOutOfRangeException">
 /// You set the <paramref name="duration"/> to a value that is less than
 /// zero.
 /// </exception>
 /// <remarks>Expired entries may be counted in <see cref="ICache{T}.Size"/>,
 /// but should never be visible to read or write operations.
 /// </remarks>
 public CacheBuilder <T> ExpireAfterAccess(TimeSpan duration)
 {
     if (duration < TimeSpan.Zero)
     {
         Thrower.ThrowArgumentOutOfRangeException(ExceptionArgument.duration);
     }
     expiry_after_access_nanos_ = (long)duration.Convert(TimeUnit.Nanoseconds);
     return(this);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Specifies that active entries are eligible for automatic refresh once
 /// a fixed duration has elapsed after the entry's creation, or the most
 /// recent replacement of its value.
 /// </summary>
 /// <param name="duration"></param>
 /// <returns></returns>
 /// <remarks>
 /// <para>
 /// The semantics of refreshes are specified in
 /// <see cref="ILoadingCache{T}.Refresh()"/>, and are performed by calling
 /// <see cref="CacheLoader{T}.Load"/>.
 /// <para>
 /// As the default implementation
 /// TODO: continue.
 /// </para>
 /// </para>
 /// </remarks>
 public CacheBuilder <T> RefreshAfterWrite(TimeSpan duration)
 {
     if (duration < TimeSpan.Zero)
     {
         Thrower.ThrowArgumentOutOfRangeException(ExceptionArgument.duration);
     }
     refresh_nanos_ = (long)duration.Convert(TimeUnit.Nanoseconds);
     return(this);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Copies the elements of the <see cref="AndersonTree{TKey,TValue}"/> to
        /// an <see cref="Array"/>, starting at a particular index.
        /// </summary>
        /// <param name="array">
        /// The one-dimensional <see cref="Array"/> that is the destination of the
        /// elements copied from the <see cref="AndersonTree{TKey,TValue}"/>.
        /// The array must have zero-based indexing.
        /// </param>
        /// <param name="index">
        /// The zero-based index in array at which copying begins.
        /// </param>
        /// <exception cref="ArgumentOutOfRangeException">
        /// <paramref name="index"/> is less than 0.
        /// </exception>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="array"/>is <c>null</c>.
        /// </exception>
        /// <exception cref="ArgumentException">
        /// <paramref name="array"/> is multidimensional.-or-
        /// <paramref name="index"/> is equal to or greater than the length of the
        /// array.-or-The number of elements in the source
        /// <see cref="AndersonTree{TKey,TValue}"/>is greater than the
        /// available space from <paramref name="index"/> to the end of the
        /// destination array.-or- <see cref=" KeyValuePair{TKey,TValue}"/> cannot
        /// be cast automatically to the type of the destination array.
        /// </exception>
        public void CopyTo(KeyValuePair <TKey, TValue>[] array, int index)
        {
            if ((index < 0) || (index > array.Length))
            {
                Thrower.ThrowArgumentOutOfRangeException(ExceptionArgument.index);
            }

            if ((array.Length - index) < count_)
            {
                Thrower.ThrowArgumentException(
                    ExceptionResource.Arg_ArrayPlusOffTooSmall);
            }

            if (count_ == 0)
            {
                return;
            }

            InOrderTreeWalk(delegate(AndersonTreeNode <TKey, TValue> node)
            {
                array[index++] = node.ToKeyValuePair();
                return(true);
            });
        }
Ejemplo n.º 5
0
 public void ThrowArgumentOutOfRangeException()
 {
     Thrower.ThrowArgumentOutOfRangeException(ExceptionArgument.any);
 }