Ejemplo n.º 1
0
 public SparseAListLeaf(SparseAListLeaf <T> original)
 {
     _list        = original._list.Clone();
     _maxNodeSize = original._maxNodeSize;
     _totalCount  = original._totalCount;
     _isFrozen    = false;
 }
Ejemplo n.º 2
0
        private void SplitLeaf(out AListNode <int, T> splitLeft, out AListNode <int, T> splitRight)
        {
            int  divAt     = _list.Count >> 1;
            uint divOffset = _list[divAt].Offset;

            splitLeft = new SparseAListLeaf <T>(_maxNodeSize, _list.CopySection(0, divAt), divOffset);
            var rightSec = _list.CopySection(divAt, _list.Count - divAt);

            AdjustOffsetsStartingAt(0, ref rightSec, -(int)divOffset);
            splitRight = new SparseAListLeaf <T>(_maxNodeSize, rightSec, _totalCount - divOffset);
        }
Ejemplo n.º 3
0
 private void SplitLeaf(out AListNode <int, T> splitLeft, out AListNode <int, T> splitRight, bool insertingAtFarRight)
 {
     if (insertingAtFarRight)
     {
         splitLeft = new SparseAListLeaf <T>(_maxNodeSize, _list.CopySection(0, _list.Count), TotalCount);
         // nodes aren't allowed to be empty, but the caller is promising to put something in it
         splitRight = new SparseAListLeaf <T>(_maxNodeSize, InternalList <Entry> .Empty, 0);
     }
     else
     {
         int  divAt     = insertingAtFarRight ? _list.Count : _list.Count >> 1;
         uint divOffset = _list[divAt].Offset;
         splitLeft = new SparseAListLeaf <T>(_maxNodeSize, _list.CopySection(0, divAt), divOffset);
         var rightSec = _list.CopySection(divAt, _list.Count - divAt);
         AdjustOffsetsStartingAt(0, ref rightSec, -(int)divOffset);
         splitRight = new SparseAListLeaf <T>(_maxNodeSize, rightSec, _totalCount - divOffset);
     }
 }