Example #1
0
        public override object Clone()
        {
            ArrayItemList <T> arrayItemList = new ArrayItemList <T>(this.Capacity);

            arrayItemList.Promote(this);
            return((object)arrayItemList);
        }
Example #2
0
        public int Add(T value)
        {
            if (this._listStore == null)
            {
                this._listStore = (FrugalListBase <T>) 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);
                    int num = (int)threeItemList.Add(value);
                    this._listStore = (FrugalListBase <T>)threeItemList;
                }
                else if (FrugalListStoreState.SixItemList == frugalListStoreState)
                {
                    SixItemList <T> sixItemList = new SixItemList <T>();
                    sixItemList.Promote(this._listStore);
                    this._listStore = (FrugalListBase <T>)sixItemList;
                    int num = (int)sixItemList.Add(value);
                    this._listStore = (FrugalListBase <T>)sixItemList;
                }
                else
                {
                    if (FrugalListStoreState.Array != frugalListStoreState)
                    {
                        throw new InvalidOperationException("FrugalList_CannotPromoteBeyondArray");
                    }
                    ArrayItemList <T> arrayItemList = new ArrayItemList <T>(this._listStore.Count + 1);
                    arrayItemList.Promote(this._listStore);
                    this._listStore = (FrugalListBase <T>)arrayItemList;
                    int num = (int)arrayItemList.Add(value);
                    this._listStore = (FrugalListBase <T>)arrayItemList;
                }
            }
            return(this._listStore.Count - 1);
        }
Example #3
0
        public void Promote(ArrayItemList <T> oldList)
        {
            int count = oldList.Count;

            if (this._entries.Length >= count)
            {
                this.SetCount(oldList.Count);
                for (int index = 0; index < count; ++index)
                {
                    this.SetAt(index, oldList.EntryAt(index));
                }
            }
            else
            {
                throw new ArgumentException(string.Format("FrugalList_TargetMapCannotHoldAllData", new object[3]
                {
                    (object)oldList.ToString(),
                    (object)this.ToString(),
                    (object)nameof(oldList)
                }));
            }
        }