Beispiel #1
0
        public void TestKMP()
        {
            var kmp = new KMP("ababc");

            Debug.WriteLine(kmp.Match("abababc"));
            Debug.WriteLine(kmp.Match("abd"));
        }
Beispiel #2
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
        });
    }
        private void _searchTextBox_OnTextChange(string oldString, string curString)
        {
            curString = curString.Trim(' ');
            if (curString == "")
            {
                _itemGrid.Clear();
                _itemGrid.AddRange(uISlots);
                return;
            }
            var kmp = new KMP(curString.ToLower());

            _itemGrid.Clear();
            var slots = new List <UISimpleSlot>();

            for (var i = 1; i < Main.itemTexture.Length; i++)
            {
                if (kmp.Match(uISlots[i - 1].Item.Name.ToLower()))
                {
                    slots.Add(uISlots[i - 1]);
                }
            }
            _itemGrid.AddRange(slots);
        }
        private void _searchTextBox_OnTextChange(string oldString, string curString)
        {
            curString = curString.Trim(' ');
            if (curString == "")
            {
                _npcGrid.Clear();
                _npcGrid.AddRange(uISlots);
                return;
            }
            var kmp = new KMP(curString.ToLower());

            _npcGrid.Clear();
            var slots = new List <UISimpleSlot>();

            for (var i = 0; i < uISlots.Count; i++)
            {
                if (kmp.Match(Lang.GetNPCNameValue(uISlots[i].Npc.netID).ToLower()))
                {
                    slots.Add(uISlots[i]);
                }
            }
            _npcGrid.AddRange(slots);
        }