internal LiveShapingItem(object item, LiveShapingList list, bool filtered = false, LiveShapingBlock block = null, bool oneTime = false)
        {
            _block = block;

            list.InitializeItem(this, item, filtered, oneTime);

            ForwardChanges = !oneTime;
        }
 // Token: 0x0600757C RID: 30076 RVA: 0x00218C28 File Offset: 0x00216E28
 protected override void Copy(RBNode <LiveShapingItem> sourceNode, int sourceOffset, RBNode <LiveShapingItem> destNode, int destOffset, int count)
 {
     base.Copy(sourceNode, sourceOffset, destNode, destOffset, count);
     if (sourceNode != destNode)
     {
         LiveShapingBlock block = (LiveShapingBlock)destNode;
         int i = 0;
         while (i < count)
         {
             destNode.GetItemAt(destOffset).Block = block;
             i++;
             destOffset++;
         }
     }
 }
Example #3
0
        protected override void Copy(RBNode <LiveShapingItem> sourceNode, int sourceOffset, RBNode <LiveShapingItem> destNode, int destOffset, int count)
        {
            #if LiveShapingInstrumentation
            ++_copies;
            _totalCopySize += count;
            #endif

            base.Copy(sourceNode, sourceOffset, destNode, destOffset, count);

            if (sourceNode != destNode)
            {
                LiveShapingBlock destBlock = (LiveShapingBlock)destNode;

                for (int k = 0; k < count; ++k, ++destOffset)
                {
                    destNode.GetItemAt(destOffset).Block = destBlock;
                }
            }
        }
Example #4
0
        // find the item in the tree to my right.  If it's smaller than the nearest clean
        // neighbor, return a finger to the given offset within this node
        RBFinger <LiveShapingItem> SearchRight(LiveShapingItem item, int offset, Comparison <LiveShapingItem> comparison)
        {
            LiveShapingBlock foundBlock = this;

            List <LiveShapingBlock> list = new List <LiveShapingBlock>();  // subtrees to explore

            list.Add(RightChildBlock);

            // phase 1, walk up the tree looking for the item in each right-parent
            LiveShapingBlock block, parent;
            int first, last, size;

            for (block = this, parent = block.ParentBlock; parent != null; block = parent, parent = block.ParentBlock)
            {
                if (parent.LeftChildBlock == block)
                {
                    parent.GetFirstAndLastCleanItems(out first, out last, out size);

                    // find where the search item belongs relative to the clean items
                    if (first >= size)
                    {   // no clean items - add the right subtree for later exploration
                        list.Add(parent.RightChildBlock);
                    }
                    else if (comparison(item, parent.GetItemAt(first)) < 0)
                    {   // item belongs to the left of parent - no need to climb higher
                        break;
                    }
                    else if (comparison(item, parent.GetItemAt(last)) <= 0)
                    {   // item belongs in the parent
                        return(parent.LocalSearch(item, first + 1, last, comparison));
                    }
                    else
                    {   // item belongs to the right of parent, thus also right of unexplored subtrees
                        list.Clear();
                        list.Add(parent.RightChildBlock);
                        foundBlock = parent;
                        offset     = last + 1;
                    }
                }
            }

            // phase 2, item wasn't found in a right-parent, so it belongs in one of the
            // unexplored subtrees.   Search them left-to-right, hoping item didn't move far.
            Stack <LiveShapingBlock> stack = new Stack <LiveShapingBlock>(list);

            while (stack.Count > 0)
            {
                block = stack.Pop();
                if (block == null)
                {
                    continue;
                }

                block.GetFirstAndLastCleanItems(out first, out last, out size);

                if (first >= size)
                {   // no clean items - explore the subtrees
                    stack.Push(block.RightChildBlock);
                    stack.Push(block.LeftChildBlock);
                }
                else if (comparison(item, block.GetItemAt(first)) < 0)
                {   // item belongs to the left
                    stack.Clear();
                    stack.Push(block.LeftChildBlock);
                }
                else if (comparison(item, block.GetItemAt(last)) <= 0)
                {   // item belongs in the current block
                    return(block.LocalSearch(item, first + 1, last, comparison));
                }
                else
                {   // item belongs to the right of the block, or possibly in it
                    foundBlock = block;
                    offset     = last + 1;
                    stack.Push(block.RightChildBlock);
                }
            }

            // phase 3, item wasn't found within any block, so put it at the
            // edge of the "found" block
            int baseIndex;

            GetRootAndIndex(foundBlock, out baseIndex);
            return(new RBFinger <LiveShapingItem>()
            {
                Node = foundBlock, Offset = offset, Index = baseIndex + offset
            });
        }
        // Token: 0x06007581 RID: 30081 RVA: 0x00219108 File Offset: 0x00217308
        private RBFinger <LiveShapingItem> SearchRight(LiveShapingItem item, int offset, Comparison <LiveShapingItem> comparison)
        {
            LiveShapingBlock        node = this;
            List <LiveShapingBlock> list = new List <LiveShapingBlock>();

            list.Add(this.RightChildBlock);
            LiveShapingBlock liveShapingBlock = this;

            for (LiveShapingBlock parentBlock = liveShapingBlock.ParentBlock; parentBlock != null; parentBlock = liveShapingBlock.ParentBlock)
            {
                if (parentBlock.LeftChildBlock == liveShapingBlock)
                {
                    int num;
                    int num2;
                    int num3;
                    parentBlock.GetFirstAndLastCleanItems(out num, out num2, out num3);
                    if (num >= num3)
                    {
                        list.Add(parentBlock.RightChildBlock);
                    }
                    else
                    {
                        if (comparison(item, parentBlock.GetItemAt(num)) < 0)
                        {
                            break;
                        }
                        if (comparison(item, parentBlock.GetItemAt(num2)) <= 0)
                        {
                            return(parentBlock.LocalSearch(item, num + 1, num2, comparison));
                        }
                        list.Clear();
                        list.Add(parentBlock.RightChildBlock);
                        node   = parentBlock;
                        offset = num2 + 1;
                    }
                }
                liveShapingBlock = parentBlock;
            }
            Stack <LiveShapingBlock> stack = new Stack <LiveShapingBlock>(list);

            while (stack.Count > 0)
            {
                liveShapingBlock = stack.Pop();
                if (liveShapingBlock != null)
                {
                    int num;
                    int num2;
                    int num3;
                    liveShapingBlock.GetFirstAndLastCleanItems(out num, out num2, out num3);
                    if (num >= num3)
                    {
                        stack.Push(liveShapingBlock.RightChildBlock);
                        stack.Push(liveShapingBlock.LeftChildBlock);
                    }
                    else if (comparison(item, liveShapingBlock.GetItemAt(num)) < 0)
                    {
                        stack.Clear();
                        stack.Push(liveShapingBlock.LeftChildBlock);
                    }
                    else
                    {
                        if (comparison(item, liveShapingBlock.GetItemAt(num2)) <= 0)
                        {
                            return(liveShapingBlock.LocalSearch(item, num + 1, num2, comparison));
                        }
                        node   = liveShapingBlock;
                        offset = num2 + 1;
                        stack.Push(liveShapingBlock.RightChildBlock);
                    }
                }
            }
            int num4;

            base.GetRootAndIndex(node, out num4);
            return(new RBFinger <LiveShapingItem>
            {
                Node = node,
                Offset = offset,
                Index = num4 + offset
            });
        }