Пример #1
0
 public void AutoEnlargeChildren(int more)
 {
     if (_childCount + more > _children.Length)
     {
         int newCapacity = InternalList.NextLargerSize(_childCount + more - 1, _maxNodeSize);
         _children = InternalList.CopyToNewArray(_children, _childCount, newCapacity);
         InitEmpties(_childCount);
     }
 }
Пример #2
0
        protected AListInnerBase(AListInnerBase <K, T> frozen)
        {
            _children    = InternalList.CopyToNewArray(frozen._children);
            _childCount  = frozen._childCount;
            _maxNodeSize = frozen._maxNodeSize;
            _isFrozen    = false;

            MarkChildrenFrozen();
            AssertValid();
        }
Пример #3
0
 public CPBitArrayLeaf(CPBitArrayLeaf <T> clone)
 {
     _flags = InternalList.CopyToNewArray(clone._flags);
     if (clone._indices != null)
     {
         _indices = InternalList.CopyToNewArray(clone._indices);
         for (int i = 0; i < _indices.Length; i++)
         {
             _indices[i] = InternalList.CopyToNewArray(_indices[i]);
         }
     }
     // TODO: shrink _values array
     _values     = InternalList.CopyToNewArray(_values);
     _localCount = clone._localCount;
     _valueCount = clone._valueCount;
 }
Пример #4
0
        private void ExtractCurrent(CPEnumerator <T> e, byte k)
        {
            Debug.Assert(IsPresent(k));

            byte[] buf  = e.Key.Buffer;
            int    offs = e.Key.Offset;

            if (buf.Length == offs)
            {
                // out of buffer space in e.Key, only need one more byte!
                buf = InternalList.CopyToNewArray(buf, offs, offs + 1);
            }
            buf[offs] = k;
            e.Key.Reset(buf, offs, 1);
            e.CurrentValue = GetValueAt(k);
        }
Пример #5
0
        private int AllocValue(T value)
        {
            int slot = AllocValueSlot();

            if (_values == null)
            {
                Debug.Assert(slot == 0);
                _values = new T[4];
            }
            else if (slot >= _values.Length)
            {
                _values = InternalList.CopyToNewArray(_values, _values.Length,
                                                      Math.Min(_values.Length << 1, 256));
            }
            _values[slot] = value;
            return(slot);
        }
Пример #6
0
        protected void EnsureCapacity(int amountToInsert)
        {
            Debug.Assert(amountToInsert >= 0);
            int newSize = _list.Count + amountToInsert;

            if (newSize > _list.Capacity)
            {
                int maxCapacity = (newSize << 1) + 2, capacity;
                if (newSize <= _maxNodeSize)
                {
                    for (capacity = _maxNodeSize; capacity > maxCapacity; capacity >>= 1)
                    {
                    }
                }
                else
                {
                    capacity = newSize;
                    Debug.Assert(false);
                }
                var newArray = InternalList.CopyToNewArray(_list.InternalArray, _list.Count, capacity);
                _list = new InternalList <T>(newArray, _list.Count);
            }
        }
Пример #7
0
 protected BListInner(BListInner <K, T> frozen) : base(frozen)
 {
     _highestKey = InternalList.CopyToNewArray(frozen._highestKey);
 }
Пример #8
0
 /// <summary>Makes a copy of the list, as an array</summary>
 public T[] ToArray()
 {
     return(InternalList.CopyToNewArray(_array, _count, _count));
 }
Пример #9
0
 /// <summary>Makes a copy of the list with Capacity = Count</summary>
 public InternalList <T> CloneAndTrim()
 {
     return(new InternalList <T>(InternalList.CopyToNewArray(_array, _count, _count), _count));
 }
Пример #10
0
 /// <summary>Makes a copy of the list with the same capacity</summary>
 public InternalList <T> Clone()
 {
     return(new InternalList <T>(InternalList.CopyToNewArray(_array, _count, _array.Length), _count));
 }