Beispiel #1
0
    public static void Main(string[] args)
    {
        KMP.CheckEQ(KMP.Build("ABCDABD"), new List <int> {
            0, 0, 0, 0, 0, 1, 2, 0
        });
        KMP.CheckEQ(KMP.Build("AB"), new List <int> {
            0, 0, 0
        });
        KMP.CheckEQ(KMP.Build("A"), new List <int> {
            0, 0
        });
        KMP.CheckEQ(KMP.Build("AA"), new List <int> {
            0, 0, 1
        });
        KMP.CheckEQ(KMP.Build("AAAA"), new List <int> {
            0, 0, 1, 2, 3
        });
        KMP.CheckEQ(KMP.Build("AABA"), new List <int> {
            0, 0, 1, 0, 1
        });


        KMP.CheckEQ(KMP.Match("ABC ABCDAB ABCDABCDABDE", "ABCDABD"), new List <int> {
            15
        });
        KMP.CheckEQ(KMP.Match("ABC ABCDAB ABCDABCDABDE", "AB"), new List <int> {
            0, 4, 8, 11, 15, 19
        });
        KMP.CheckEQ(KMP.Match("ABC ABCDAB ABCDABCDABDE", "B"), new List <int> {
            1, 5, 9, 12, 16, 20
        });
        KMP.CheckEQ(KMP.Match("AAAAA", "A"), new List <int> {
            0, 1, 2, 3, 4
        });
        KMP.CheckEQ(KMP.Match("AAAAA", "AA"), new List <int> {
            0, 1, 2, 3
        });
        KMP.CheckEQ(KMP.Match("AAAAA", "AAA"), new List <int> {
            0, 1, 2
        });
        KMP.CheckEQ(KMP.Match("ABC", "ABC"), new List <int> {
            0
        });
    }