Beispiel #1
0
 private static void VerifyValueType(object value)
 {
     if (!ObjectArray <T> .IsCompatibleObject(value))
     {
         throw new Exception("ThrowHelper.ThrowWrongValueTypeArgumentException(value, typeof(T)");
     }
 }
Beispiel #2
0
        object IList.this[int index]
        {
            get
            {
                //checkAndGrow(index);
                int diff = index + 1 - _size;
                for (int i = 0; i < diff; ++i)
                {
                    Add(new T());
                }

                return(this[index]);
            }
            set
            {
                //checkAndGrow(index);
                int diff = index + 1 - _size;
                for (int i = 0; i < diff; ++i)
                {
                    Add(new T());
                }

                ObjectArray <T> .VerifyValueType(value);

                this[index] = (T)value;
            }
        }
Beispiel #3
0
 internal Enumerator(ObjectArray <T> list)
 {
     this.list    = list;
     this.index   = 0;
     this.version = list._version;
     this.current = default(T);
 }
Beispiel #4
0
 void IList.Remove(object item)
 {
     if (ObjectArray <T> .IsCompatibleObject(item))
     {
         this.Remove((T)item);
     }
 }
Beispiel #5
0
        int IList.Add(object item)
        {
            ObjectArray <T> .VerifyValueType(item);

            this.Add((T)item);
            return(this.Count - 1);
        }
Beispiel #6
0
 int IList.IndexOf(object item)
 {
     if (ObjectArray <T> .IsCompatibleObject(item))
     {
         return(this.IndexOf((T)item));
     }
     return(-1);
 }
Beispiel #7
0
            public bool MoveNext()
            {
                ObjectArray <T> list = this.list;

                if ((this.version == list._version) && (this.index < list._size))
                {
                    this.current = list._items[this.index];
                    this.index++;
                    return(true);
                }
                return(this.MoveNextRare());
            }
Beispiel #8
0
        public void Sort(Comparison <T> comparison)
        {
            if (comparison == null)
            {
                throw new Exception("ThrowHelper.ThrowArgumentNullException(ExceptionArgument.match");
            }
            if (this._size > 0)
            {
                IComparer <T> comparer = new ObjectArray <T> .FunctorComparer(comparison);

                Array.Sort <T>(this._items, 0, this._size, comparer);
            }
        }
Beispiel #9
0
        public ObjectArray <TOutput> ConvertAll <TOutput>(Converter <T, TOutput> converter) where TOutput : new()
        {
            if (converter == null)
            {
                throw new Exception("ThrowHelper.ThrowArgumentNullException(ExceptionArgument.converter");
            }
            ObjectArray <TOutput> list = new ObjectArray <TOutput>(this._size);

            for (int i = 0; i < this._size; i++)
            {
                list._items[i] = converter(this._items[i]);
            }
            list._size = this._size;
            return(list);
        }
Beispiel #10
0
        //public Enumerator<T> GetEnumerator()
        //{
        //    return new Enumerator<T>((ObjectArray<T>)this);
        //}

        public ObjectArray <T> GetRange(int index, int count)
        {
            if ((index < 0) || (count < 0))
            {
                throw new Exception("ThrowHelper.ThrowArgumentOutOfRangeException((index < 0) ? ExceptionArgument.index : ExceptionArgument.count, ExceptionResource.ArgumentOutOfRange_NeedNonNegNum");
            }
            if ((this._size - index) < count)
            {
                throw new Exception("ExceptionResource  - Offlen");
            }
            ObjectArray <T> list = new ObjectArray <T>(count);

            Array.Copy(this._items, index, list._items, 0, count);
            list._size = count;
            return(list);
        }
Beispiel #11
0
        public ObjectArray <T> FindAll(Predicate <T> match)
        {
            if (match == null)
            {
                throw new Exception("ThrowHelper.ThrowArgumentNullException(ExceptionArgument.match");
            }
            ObjectArray <T> list = new ObjectArray <T>();

            for (int i = 0; i < this._size; i++)
            {
                if (match(this._items[i]))
                {
                    list.Add(this._items[i]);
                }
            }
            return(list);
        }
Beispiel #12
0
        void IList.Insert(int index, object item)
        {
            ObjectArray <T> .VerifyValueType(item);

            this.Insert(index, (T)item);
        }
Beispiel #13
0
 bool IList.Contains(object item)
 {
     return(ObjectArray <T> .IsCompatibleObject(item) && this.Contains((T)item));
 }