public override object Clone()
        {
            ArrayItemList <T> list = new ArrayItemList <T>(this.Capacity);

            list.Promote((ArrayItemList <T>) this);
            return(list);
        }
        public void Promote(ArrayItemList <T> oldList)
        {
            int count = oldList.Count;

            if (this._entries.Length < count)
            {
                throw new ArgumentException(System.Xaml.SR.Get("FrugalList_TargetMapCannotHoldAllData", new object[] { oldList.ToString(), this.ToString() }), "oldList");
            }
            this.SetCount(oldList.Count);
            for (int i = 0; i < count; i++)
            {
                this.SetAt(i, oldList.EntryAt(i));
            }
        }
        public int Add(T value)
        {
            if (this._listStore == null)
            {
                this._listStore = new SingleItemList <T>();
            }
            FrugalListStoreState state = this._listStore.Add(value);

            if (state != FrugalListStoreState.Success)
            {
                if (FrugalListStoreState.ThreeItemList != state)
                {
                    if (FrugalListStoreState.SixItemList != state)
                    {
                        if (FrugalListStoreState.Array != state)
                        {
                            throw new InvalidOperationException(System.Xaml.SR.Get("FrugalList_CannotPromoteBeyondArray"));
                        }
                        ArrayItemList <T> list3 = new ArrayItemList <T>(this._listStore.Count + 1);
                        list3.Promote(this._listStore);
                        this._listStore = list3;
                        list3.Add(value);
                        this._listStore = list3;
                    }
                    else
                    {
                        SixItemList <T> list2 = new SixItemList <T>();
                        list2.Promote(this._listStore);
                        this._listStore = list2;
                        list2.Add(value);
                        this._listStore = list2;
                    }
                }
                else
                {
                    ThreeItemList <T> list = new ThreeItemList <T>();
                    list.Promote(this._listStore);
                    list.Add(value);
                    this._listStore = list;
                }
            }
            return(this._listStore.Count - 1);
        }