public override object Clone() { ArrayItemList <T> arrayItemList = new ArrayItemList <T>(this.Capacity); arrayItemList.Promote(this); return(arrayItemList); }
public int Add(T value) { if (this._listStore == null) { this._listStore = new SingleItemList <T>(); } FrugalListStoreState frugalListStoreState = this._listStore.Add(value); if (frugalListStoreState != FrugalListStoreState.Success) { if (FrugalListStoreState.ThreeItemList == frugalListStoreState) { ThreeItemList <T> threeItemList = new ThreeItemList <T>(); threeItemList.Promote(this._listStore); threeItemList.Add(value); this._listStore = threeItemList; } else if (FrugalListStoreState.SixItemList != frugalListStoreState) { if (FrugalListStoreState.Array != frugalListStoreState) { throw new InvalidOperationException(); } ArrayItemList <T> arrayItemList = new ArrayItemList <T>(this._listStore.Count + 1); arrayItemList.Promote(this._listStore); this._listStore = arrayItemList; arrayItemList.Add(value); this._listStore = arrayItemList; } else { SixItemList <T> sixItemList = new SixItemList <T>(); sixItemList.Promote(this._listStore); this._listStore = sixItemList; sixItemList.Add(value); this._listStore = sixItemList; } } return(this._listStore.Count - 1); }