Пример #1
0
 internal Enumerator(SparseList <T> list)
 {
     if (list == null)
     {
         throw new InternalErrorException(new ArgumentNullException("list"));
     }
     this.list            = list;
     this.currentIndex    = -1;
     this.requiredVersion = this.list.version;
     this.currentValue    = default(T);
 }
Пример #2
0
 public SparseQueue(int capacity, int segmentLengthLog2 = 7)
 {
     if (capacity < 0)
     {
         throw new ArgumentOutOfRangeException("Must be non-negative", "capacity");
     }
     if (segmentLengthLog2 < 0)
     {
         throw new ArgumentOutOfRangeException($"segmentLengthLog2={segmentLengthLog2.ToString()} but must be non-negative");
     }
     this._array = new SparseList <T>(segmentLengthLog2);
     this._array.Resize(this.RoundUpToSegmentBoundary(capacity));
 }
Пример #3
0
        public SynchronizedEnumerator <T> GetEnumerator()
        {
            List <T> source = this.source as List <T>;

            if (source != null)
            {
                return(new SynchronizedEnumerator <T, List <T> .Enumerator>(this.sync, source.GetEnumerator()));
            }
            SegmentedList <T> list2 = this.source as SegmentedList <T>;

            if (list2 != null)
            {
                return(new SynchronizedEnumerator <T, SegmentedList <T> .Enumerator>(this.sync, list2.GetEnumerator()));
            }
            SparseList <T> list3 = this.source as SparseList <T>;

            if (list3 != null)
            {
                return(new SynchronizedEnumerator <T, SparseList <T> .Enumerator>(this.sync, list3.GetEnumerator()));
            }
            return(new SynchronizedEnumerator <T, IEnumerator <T> >(this.sync, this.source.GetEnumerator()));
        }
Пример #4
0
 public void Dispose()
 {
     this.list         = null;
     this.currentIndex = -2;
     this.currentValue = default(T);
 }