Exemplo n.º 1
0
        // void CopyTo(T[] array, int arrayIndex)
        internal void CopyTo <T>(T[] array, int arrayIndex)
        {
            if (array == null)
            {
                throw new ArgumentNullException(nameof(array));
            }

            if (arrayIndex < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(arrayIndex));
            }

            if (array.Length <= arrayIndex && Count <T>() > 0)
            {
                throw new ArgumentException(SR.Argument_IndexOutOfArrayBounds);
            }

            if (array.Length - arrayIndex < Count <T>())
            {
                throw new ArgumentException(SR.Argument_InsufficientSpaceToCopyCollection);
            }


            IVector <T> _this = Unsafe.As <IVector <T> >(this);
            int         count = Count <T>();

            for (int i = 0; i < count; i++)
            {
                array[i + arrayIndex] = VectorToListAdapter.GetAt <T>(_this, (uint)i);
            }
        }
Exemplo n.º 2
0
        // bool Remove(T item)
        internal bool Remove <K, V>(KeyValuePair <K, V> item)
        {
            object _this = JitHelpers.UnsafeCast <object>(this);

            IDictionary <K, V> _this_dictionary = _this as IDictionary <K, V>;

            if (_this_dictionary != null)
            {
                return(_this_dictionary.Remove(item.Key));
            }
            else
            {
                IVector <KeyValuePair <K, V> > _this_vector = JitHelpers.UnsafeCast <IVector <KeyValuePair <K, V> > >(this);
                uint index;
                bool exists = _this_vector.IndexOf(item, out index);

                if (!exists)
                {
                    return(false);
                }

                if (((uint)Int32.MaxValue) < index)
                {
                    throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CollectionBackingListTooLarge"));
                }

                VectorToListAdapter.RemoveAtHelper <KeyValuePair <K, V> >(_this_vector, index);
                return(true);
            }
        }
        // void CopyTo(T[] array, int arrayIndex)
        internal void CopyTo <T>(T[] array, int arrayIndex)
        {
            if (array == null)
            {
                throw new ArgumentNullException(nameof(array));
            }

            if (arrayIndex < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(arrayIndex));
            }

            if (array.Length <= arrayIndex && Count <T>() > 0)
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_IndexOutOfArrayBounds"));
            }

            if (array.Length - arrayIndex < Count <T>())
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_InsufficientSpaceToCopyCollection"));
            }

            Contract.EndContractBlock();

            IVector <T> _this = JitHelpers.UnsafeCast <IVector <T> >(this);
            int         count = Count <T>();

            for (int i = 0; i < count; i++)
            {
                array[i + arrayIndex] = VectorToListAdapter.GetAt <T>(_this, (uint)i);
            }
        }
        // bool Remove(T item)
        internal bool Remove <K, V>(KeyValuePair <K, V> item)
        {
            object _this = Unsafe.As <object>(this);

            if (_this is IDictionary <K, V> _this_dictionary)
            {
                return(_this_dictionary.Remove(item.Key));
            }
            else
            {
                IVector <KeyValuePair <K, V> > _this_vector = Unsafe.As <IVector <KeyValuePair <K, V> > >(this);
                uint index;
                bool exists = _this_vector.IndexOf(item, out index);

                if (!exists)
                {
                    return(false);
                }

                if (((uint)int.MaxValue) < index)
                {
                    throw new InvalidOperationException(SR.InvalidOperation_CollectionBackingListTooLarge);
                }

                VectorToListAdapter.RemoveAtHelper <KeyValuePair <K, V> >(_this_vector, index);
                return(true);
            }
        }
Exemplo n.º 5
0
        internal void CopyTo <T>(T[] array, int arrayIndex)
        {
            if (array == null)
            {
                throw new ArgumentNullException("array");
            }
            if (arrayIndex < 0)
            {
                throw new ArgumentOutOfRangeException("arrayIndex");
            }
            if (array.Length <= arrayIndex && this.Count <T>() > 0)
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_IndexOutOfArrayBounds"));
            }
            if (array.Length - arrayIndex < this.Count <T>())
            {
                throw new ArgumentException(Environment.GetResourceString("Argument_InsufficientSpaceToCopyCollection"));
            }
            IVector <T> _this = JitHelpers.UnsafeCast <IVector <T> >((object)this);
            int         num   = this.Count <T>();

            for (int index = 0; index < num; ++index)
            {
                array[index + arrayIndex] = VectorToListAdapter.GetAt <T>(_this, (uint)index);
            }
        }
Exemplo n.º 6
0
 internal void RemoveAt <T>(int index)
 {
     if (index < 0)
     {
         throw new ArgumentOutOfRangeException("index");
     }
     VectorToListAdapter.RemoveAtHelper <T>(JitHelpers.UnsafeCast <IVector <T> >((object)this), (uint)index);
 }
Exemplo n.º 7
0
 internal void Insert <T>(int index, T item)
 {
     if (index < 0)
     {
         throw new ArgumentOutOfRangeException("index");
     }
     VectorToListAdapter.InsertAtHelper <T>(JitHelpers.UnsafeCast <IVector <T> >((object)this), (uint)index, item);
 }
Exemplo n.º 8
0
 internal void Indexer_Set <T>(int index, T value)
 {
     if (index < 0)
     {
         throw new ArgumentOutOfRangeException("index");
     }
     VectorToListAdapter.SetAt <T>(JitHelpers.UnsafeCast <IVector <T> >((object)this), (uint)index, value);
 }
Exemplo n.º 9
0
 internal T Indexer_Get <T>(int index)
 {
     if (index < 0)
     {
         throw new ArgumentOutOfRangeException("index");
     }
     return(VectorToListAdapter.GetAt <T>(JitHelpers.UnsafeCast <IVector <T> >((object)this), (uint)index));
 }
Exemplo n.º 10
0
        internal bool Remove <T>(T item)
        {
            IVector <T> _this = JitHelpers.UnsafeCast <IVector <T> >((object)this);
            uint        index;

            if (!_this.IndexOf(item, out index))
            {
                return(false);
            }
            if ((uint)int.MaxValue < index)
            {
                throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CollectionBackingListTooLarge"));
            }
            VectorToListAdapter.RemoveAtHelper <T>(_this, index);
            return(true);
        }
        internal bool Remove <T>(T item)
        {
            IVector <T> vector = JitHelpers.UnsafeCast <IVector <T> >(this);
            uint        num;

            if (!vector.IndexOf(item, out num))
            {
                return(false);
            }
            if (2147483647U < num)
            {
                throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CollectionBackingListTooLarge"));
            }
            VectorToListAdapter.RemoveAtHelper <T>(vector, num);
            return(true);
        }
Exemplo n.º 12
0
        // bool Remove(T item)
        internal bool Remove <T>(T item)
        {
            IVector <T> _this = Unsafe.As <IVector <T> >(this);

            bool exists = _this.IndexOf(item, out uint index);

            if (!exists)
            {
                return(false);
            }

            if (((uint)int.MaxValue) < index)
            {
                throw new InvalidOperationException(SR.InvalidOperation_CollectionBackingListTooLarge);
            }

            VectorToListAdapter.RemoveAtHelper <T>(_this, index);
            return(true);
        }
Exemplo n.º 13
0
        internal bool Remove <K, V>(KeyValuePair <K, V> item)
        {
            IDictionary <K, V> dictionary = JitHelpers.UnsafeCast <object>((object)this) as IDictionary <K, V>;

            if (dictionary != null)
            {
                return(dictionary.Remove(item.Key));
            }
            IVector <KeyValuePair <K, V> > _this = JitHelpers.UnsafeCast <IVector <KeyValuePair <K, V> > >((object)this);
            uint index;

            if (!_this.IndexOf(item, out index))
            {
                return(false);
            }
            if ((uint)int.MaxValue < index)
            {
                throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CollectionBackingListTooLarge"));
            }
            VectorToListAdapter.RemoveAtHelper <KeyValuePair <K, V> >(_this, index);
            return(true);
        }
        internal bool Remove <K, V>(KeyValuePair <K, V> item)
        {
            object             obj        = JitHelpers.UnsafeCast <object>(this);
            IDictionary <K, V> dictionary = obj as IDictionary <K, V>;

            if (dictionary != null)
            {
                return(dictionary.Remove(item.Key));
            }
            IVector <KeyValuePair <K, V> > vector = JitHelpers.UnsafeCast <IVector <KeyValuePair <K, V> > >(this);
            uint num;

            if (!vector.IndexOf(item, out num))
            {
                return(false);
            }
            if (2147483647U < num)
            {
                throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CollectionBackingListTooLarge"));
            }
            VectorToListAdapter.RemoveAtHelper <KeyValuePair <K, V> >(vector, num);
            return(true);
        }