コード例 #1
0
        static void Main()
        {
            var strings = new string[]
            {
                "a",
                "b",
                "ab",
                "bab",
                "bc",
                "bca",
                "c",
                "caa"
            };

            var root = new Trie();

            foreach (var str in strings)
            {
                root.AddString(str);
            }

            root.Precompute();


            var text = "asdbbasbcbascbabcbabcsabc";

            Console.WriteLine(text);
            root.AhoCorasick(text);
        }
コード例 #2
0
        public static void Main()
        {
            var strings = new string[]
            {
                "a",
                "aa",
                "aaa",
                "aaaa",
            };

            var trie = new Trie();

            strings.ToList().ForEach(x => trie.AddString(x));

            //trie.DFS();

            trie.Precompute();

            string text = "aaaaa";

            System.Console.WriteLine(text);

            trie.AhoCorasick(text);
        }