Пример #1
0
        public override IEdge Split(IEdge edge, int splitAt)
        {
            // This is a leaf node with both start and end indices pointing to
            // terminating symbol. Don't insert this.
            if (splitAt == Sequence.Count)
            {
                return(edge);
            }

            PersistentMultiWaySuffixEdge pmwCurrentEdge = edge as PersistentMultiWaySuffixEdge;

            if (pmwCurrentEdge == null)
            {
                return(base.Split(edge, splitAt));
            }

            // Create the new edge
            PersistentMultiWaySuffixEdge newEdge =
                new PersistentMultiWaySuffixEdge(splitAt + 1, pmwCurrentEdge.EndIndex, MaximumChildrenCount);

            // Copy the children of old edge to new edge
            newEdge.ReplaceChildren(pmwCurrentEdge.GetChildren());

            // Write the edge to storage
            newEdge.Key = EdgeStore.Write(newEdge);

            // Update the old edge
            pmwCurrentEdge.EndIndex = splitAt;

            // Set new edge as child edge to old edge
            pmwCurrentEdge.ClearChildren();
            pmwCurrentEdge.AddChild(newEdge.Key);
            Count++;

            // Update the edge in storage
            EdgeStore.Write(pmwCurrentEdge);

            return(pmwCurrentEdge);
        }