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