private static void VerifyValueType(object value) { if (!ObjectArray <T> .IsCompatibleObject(value)) { throw new Exception("ThrowHelper.ThrowWrongValueTypeArgumentException(value, typeof(T)"); } }
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; } }
internal Enumerator(ObjectArray <T> list) { this.list = list; this.index = 0; this.version = list._version; this.current = default(T); }
void IList.Remove(object item) { if (ObjectArray <T> .IsCompatibleObject(item)) { this.Remove((T)item); } }
int IList.Add(object item) { ObjectArray <T> .VerifyValueType(item); this.Add((T)item); return(this.Count - 1); }
int IList.IndexOf(object item) { if (ObjectArray <T> .IsCompatibleObject(item)) { return(this.IndexOf((T)item)); } return(-1); }
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()); }
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); } }
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); }
//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); }
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); }
void IList.Insert(int index, object item) { ObjectArray <T> .VerifyValueType(item); this.Insert(index, (T)item); }
bool IList.Contains(object item) { return(ObjectArray <T> .IsCompatibleObject(item) && this.Contains((T)item)); }