Exemplo n.º 1
0
        public override object Clone()
        {
            ThreeItemList <T> threeItemList = new ThreeItemList <T>();

            threeItemList.Promote(this);
            return(threeItemList);
        }
Exemplo n.º 2
0
        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);
        }