Пример #1
0
 public void Clear()
 {
     lock (_marksSyncRoot)
     {
         if (_positions != null)
         {
             _positions.ForEachInOrder(IncludeTextToScreenUpdate);
             _positions  = null;
             _markLength = 0;
         }
     }
 }
Пример #2
0
 public void ForEachInOrder(NodeValueAction action)
 {
     if (Left != null)
     {
         Left.ForEachInOrder(action);
     }
     action(x);
     if (Right != null)
     {
         Right.ForEachInOrder(action);
     }
 }
Пример #3
0
        public void ReplaceMarks(TextOccurences occurences, int start, int end, int tailOffset)
        {
            if (occurences == null)
            {
                throw new ArgumentNullException("occurences");
            }

            lock (_marksSyncRoot)
            {
                if (_positions == null)
                {
                    ReplaceMarks(occurences);
                    return;
                }

                Treap markThatContainsStart = FindMarkThatContainsPosition(_positions, start);
                if (markThatContainsStart != null)
                {
                    start = markThatContainsStart.x;
                }

                Treap right   = null;
                Treap garbage = null;
                _positions.Split(start - 1, out _positions, out right);

                if (right != null)
                {
                    right.Split(end, out garbage, out right);
                }

                if (garbage != null)
                {
                    garbage.ForEachInOrder(IncludeTextToScreenUpdate);
                }

                if (occurences != TextOccurences.Empty && occurences.Count > 0)
                {
                    _markLength = occurences.TextLength;
                    occurences.Positions.ForEachInOrder(IncludeTextToScreenUpdate);
                    _positions = Treap.Merge(_positions, occurences.Positions);
                }

                if (right != null)
                {
                    TreapBuilder shiftedMarks = new TreapBuilder();
                    right.ForEachInOrder((x) => { shiftedMarks.Add(x + tailOffset); });
                    _positions = Treap.Merge(_positions, shiftedMarks.ToTreap());
                }
            }
        }