コード例 #1
0
 private void EnsureCapacity(int count)
 {
     if (count > this.m_capacity)
     {
         if (this.m_array == null && this.m_buckets == null)
         {
             StorableArray storableArray = new StorableArray();
             storableArray.Array = new object[count];
             int emptySize = storableArray.EmptySize;
             if (this.m_bucketPinState == BucketPinState.UntilBucketFull || this.m_bucketPinState == BucketPinState.UntilListEnd)
             {
                 this.m_array = this.m_cache.AllocateAndPin <StorableArray>(storableArray, this.m_priority, emptySize);
             }
             else
             {
                 this.m_array = this.m_cache.Allocate <StorableArray>(storableArray, this.m_priority, emptySize);
             }
             this.m_capacity = count;
         }
         if (this.m_array != null)
         {
             if (count <= this.m_bucketSize)
             {
                 int num = Math.Min(Math.Max(count, this.m_capacity * 2), this.m_bucketSize);
                 using (this.m_array.PinValue())
                 {
                     StorableArray storableArray2 = this.m_array.Value();
                     Array.Resize <object>(ref storableArray2.Array, num);
                 }
                 this.m_capacity = num;
             }
             else
             {
                 if (this.m_capacity < this.m_bucketSize)
                 {
                     using (this.m_array.PinValue())
                     {
                         StorableArray storableArray3 = this.m_array.Value();
                         Array.Resize <object>(ref storableArray3.Array, this.m_bucketSize);
                     }
                     this.m_capacity = this.m_bucketSize;
                 }
                 this.m_buckets = new ScalableList <IReference <StorableArray> >(this.m_priority, this.m_cache, 100, 10, this.m_bucketPinState == BucketPinState.UntilListEnd);
                 this.m_buckets.Add(this.m_array);
                 this.m_array = null;
             }
         }
         if (this.m_buckets != null)
         {
             while (this.GetBucketIndex(count - 1) >= this.m_buckets.Count)
             {
                 StorableArray storableArray4 = new StorableArray();
                 storableArray4.Array = new object[this.m_bucketSize];
                 int emptySize2 = storableArray4.EmptySize;
                 if (this.m_bucketPinState == BucketPinState.UntilListEnd)
                 {
                     IReference <StorableArray> item = this.m_cache.AllocateAndPin <StorableArray>(storableArray4, this.m_priority, emptySize2);
                     this.m_buckets.Add(item);
                 }
                 else if (this.m_bucketPinState == BucketPinState.UntilBucketFull)
                 {
                     IReference <StorableArray> item = this.m_cache.AllocateAndPin <StorableArray>(storableArray4, this.m_priority, emptySize2);
                     this.m_buckets.AddAndPin(item);
                 }
                 else
                 {
                     IReference <StorableArray> item = this.m_cache.Allocate <StorableArray>(storableArray4, this.m_priority, emptySize2);
                     this.m_buckets.Add(item);
                 }
                 this.m_capacity += this.m_bucketSize;
             }
         }
     }
 }
コード例 #2
0
 public ScalableHybridList(int scalabilityPriority, IScalabilityCache cache, int segmentSize, int initialCapacity)
 {
     this.m_entries = new ScalableList <ScalableHybridListEntry>(scalabilityPriority, cache, segmentSize, initialCapacity);
 }
コード例 #3
0
 public static int SizeOf <T>(ScalableList <T> obj)
 {
     return(ItemSizes.SizeOf((IStorable)obj));
 }