Exemplo n.º 1
0
        private void SplitLinkedNodeAndAddNewKeyNode(int start, int end, int value, int matchingCharCount)
        {
            //Splits "this" into two LinkedNodes and adds new KeyNode for current suffix
            var newLinkedNode = new LinkedNode(Start + matchingCharCount, End)
            {
                Children = Children
            };

            Children = new LinkedList <IChildNode>();
            Children.AddLast(newLinkedNode);
            End = Start + matchingCharCount;
            var newKeyNode = new KeyNode(start + matchingCharCount, end, value);

            Children.AddLast(newKeyNode);
        }
Exemplo n.º 2
0
        private void SplitKeyNodeAndAddBothToNewLinkedNode(string text, KeyNode node, int start, int end, int value)
        {
            //Count matching chars
            var count = CountMatchingChars(text, start, end, node.Start);

            //Replace node with new LinkedNode with lenth og the count of charmatches and add two KeyNodes.
            //One for node and one for the current value
            var newLinkedNode = new LinkedNode(node.Start, node.Start + count);
            var newKeyNode1   = new KeyNode(node.Start + count, node.End, node.Value);
            var newKeyNode2   = new KeyNode(start + count, end, value);

            newLinkedNode.Children.AddLast(newKeyNode1);
            newLinkedNode.Children.AddLast(newKeyNode2);
            Children.Remove(node);
            Children.AddFirst(newLinkedNode);
        }