Beispiel #1
0
        /// <summary>
        /// Correspones To: S[i]
        /// </summary>
        /// <param name="index"></param>
        /// <returns><see cref="QsSequenceElement"/></returns>
        public new QsSequenceElement this[int index]
        {
            get
            {
                QsSequenceElement el;
                if (!this.TryGetValue(index, out el))
                {
                    //failed to get the value
                    // here the magic begins

                    if (index > 0)
                    {
                        int IX = index;
                        while (!this.ContainsKey(IX))
                        {
                            IX--;  //decrease the index.
                        }
                        //Bingo we found it
                        this.TryGetValue(IX, out el);
                    }
                    else if (index < 0)
                    {
                        int IX = index;
                        while (!this.ContainsKey(IX))
                        {
                            IX++;  //decrease the index.
                        }
                        //Bingo we found it
                        this.TryGetValue(IX, out el);
                    }
                    else
                    {
                        //zero and not found the in logical error or some one altered the zero element.
                        throw new QsException("Damn it. Where is the zero element");
                    }
                }
                return(el);
            }
            set
            {
                if (index < MinimumIndex)
                {
                    MinimumIndex = index;
                }
                if (index > MaximumIndex)
                {
                    MaximumIndex = index;
                }

                value.ParentSequence        = this;
                value.IndexInParentSequence = index;
                base[index] = value;

                //clear the cache
                CachedValues.Clear();
            }
        }
Beispiel #2
0
 private void Finallize()
 {
     CachedValues?.Clear();
     CachedValues2?.Clear();
 }
Beispiel #3
0
 public void DeleteUnnecessaryData()
 {
     CachedValues?.Clear();
     CachedValues2?.Clear();
 }