Example #1
0
 void IList.Remove(object item)
 {
     if (ObjectArray <T> .IsCompatibleObject(item))
     {
         this.Remove((T)item);
     }
 }
Example #2
0
 private static void VerifyValueType(object value)
 {
     if (!ObjectArray <T> .IsCompatibleObject(value))
     {
         throw new Exception("ThrowHelper.ThrowWrongValueTypeArgumentException(value, typeof(T)");
     }
 }
Example #3
0
        int IList.Add(object item)
        {
            ObjectArray <T> .VerifyValueType(item);

            this.Add((T)item);
            return(this.Count - 1);
        }
Example #4
0
 internal Enumerator(ObjectArray <T> list)
 {
     this.list    = list;
     this.index   = 0;
     this.version = list._version;
     this.current = default(T);
 }
Example #5
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;
            }
        }
Example #6
0
 int IList.IndexOf(object item)
 {
     if (ObjectArray <T> .IsCompatibleObject(item))
     {
         return(this.IndexOf((T)item));
     }
     return(-1);
 }
Example #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());
            }
Example #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 <T>(comparison);

                Array.Sort <T>(this._items, 0, this._size, comparer);
            }
        }
Example #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);
        }
Example #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);
        }
Example #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);
        }
Example #12
0
        void IList.Insert(int index, object item)
        {
            ObjectArray <T> .VerifyValueType(item);

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