Example #1
0
        public CharacterNode(string fragment, BaseTrieNode baseNode)
            : base(fragment)
        {
            Guard.ArgumentNotNull(baseNode, nameof(baseNode));

            FailNode = baseNode;
        }
 private void UpdateFailNodeForEachFragment(BaseTrieNode baseNode)
 {
     foreach (var fragment in GetFragments(baseNode.Fragment))
     {
         UpdateFailNodeIfNotRootOrSelf(fragment, baseNode);
     }
 }
        private void UpdateFailNodeIfNotRootOrSelf(string fragment, BaseTrieNode baseNode)
        {
            var failNode = trie.Find(fragment);

            if (!failNode.IsRoot && failNode != baseNode)
            {
                baseNode.UpdateFailNode(failNode);
            }
        }
Example #4
0
        public void Iterate(RootNode rootNode)
        {
            Guard.ArgumentNotNull(rootNode, nameof(rootNode));

            Cursor = rootNode;

            foreach (var chracter in term)
            {
                Cursor = Cursor.Seek(chracter);
            }
        }
Example #5
0
        public void Iterate(RootNode rootNode)
        {
            Guard.ArgumentNotNull(rootNode, nameof(rootNode));

            var stringBuilder = new StringBuilder();

            BaseTrieNode cursor = rootNode;

            foreach (var character in term)
            {
                stringBuilder.Append(character);

                var result = cursor.CharacterNodes.ContainsKey(character);

                if (!result)
                {
                    cursor.CharacterNodes[character] = new CharacterNode(stringBuilder.ToString(), cursor);
                }

                cursor = cursor.Seek(character);
            }

            cursor.UpdateTerm(term);
        }
Example #6
0
 public override void UpdateFailNode(BaseTrieNode baseNode)
 {
     throw new InvalidOperationException();
 }