Esempio n. 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (BM.Checked)
            {
                if (textBox1.TextLength > 0)
                {
                    BMSearch.BoyerMoore BM = new BMSearch.BoyerMoore(textBox1.Text);
                    BM.Initialize(textBox1.Text);
                    int A = BM.Search(txt.txt);
                    A = BM.bmSearch(textBox1.Text, txt.txt);
                    if (A == 0)
                    {
                        MessageBox.Show("Ni ma");
                    }
                    else
                    {
                        MessageBox.Show("Występoje " + Convert.ToString(A) + "  razy");
                    }
                }
            }

            if (KMP_box.Checked)
            {
                if (textBox1.TextLength > 0)
                {
                    int KMP = txt.KMPSearch(textBox1.Text);
                    if (KMP == 0)
                    {
                        MessageBox.Show("Ni ma");
                    }
                    else
                    {
                        MessageBox.Show("Występoje " + Convert.ToString(KMP) + "  razy");
                    }
                }
            }
            if (sunday_box.Checked)
            {
                if (textBox1.TextLength > 0)
                {
                    int Sunday     = txt.SundaySeartch(textBox1.Text);
                    int SundayMeta = txt.SundayMeta(textBox1.Text);
                    if (Sunday == 0)
                    {
                        MessageBox.Show("Ni ma");
                    }
                    else
                    {
                        MessageBox.Show("Występoje Sunday" + Convert.ToString(Sunday) + "  razy");
                    }
                    MessageBox.Show("Występoje MetaSunday " + Convert.ToString(SundayMeta) + "  razy");
                }
            }
        }
Esempio n. 2
0
        private void button_badaj_Click(object sender, EventArgs e)
        {
            bool wzorzeclosuj = true;

            if (Lbox.Checked)
            {
                string text = Algorytmy.Properties.Resources.tekstLosowy;
                T = text;
            }
            if (DNA_box.Checked)
            {
                string text = Algorytmy.Properties.Resources.DNA;
                T = text;
            }
            if (Tbox.Checked)
            {
                string text = Algorytmy.Properties.Resources.Tadek;
                T = text;
            }
            foreach (var series in chart1.Series)
            {
                series.Points.Clear();
            }
            if (KW_BOX.Checked)
            {
                wzorzeclosuj = false;
                PT           = textBox4.Text;
            }
            foreach (var series in chart2.Series)
            {
                series.Points.Clear();
            }
            char   litera;
            string U;

            if (wzorzeclosuj == true)
            {
                for (int i = 0; i < Convert.ToInt32(Patern_min.Text); i++)
                {
                    litera = (char)losuj.Next(65, 65 + Convert.ToInt32(Alfabet.Text));
                    PT    += litera;
                }
            }
            for (int u = Convert.ToInt32(Text_min.Text); u < Convert.ToInt32(Tekst_max.Text); u = u + 1000)
            {
                U   = T;
                U   = U.Remove(u);
                txt = new Tekst(U);
                chart1.Update();

                if (KMP_box.Checked)
                {
                    var watchKMP = System.Diagnostics.Stopwatch.StartNew();
                    txt.KMPSearch(PT);
                    watchKMP.Stop();
                    chart1.Series["KMP"].Points.AddXY((double)u, Convert.ToInt32(watchKMP.ElapsedTicks));
                }
                if (sunday_box.Checked)
                {
                    var watchSunday = System.Diagnostics.Stopwatch.StartNew();
                    txt.SundaySeartch(PT);
                    watchSunday.Stop();
                    chart1.Series["Sunday"].Points.AddXY((double)u, Convert.ToInt32(watchSunday.ElapsedTicks));
                }
                if (BM.Checked)
                {
                    txt.preBM(PT);
                    var watchBM = System.Diagnostics.Stopwatch.StartNew();
                    txt.BMSeartch();
                    watchBM.Stop();
                    chart1.Series["BM"].Points.AddXY((double)u, Convert.ToInt32(watchBM.ElapsedTicks));
                }
            }
            ////////////////////Wzorzec
            PT = PT.Remove(0);
            if (wzorzeclosuj)
            {
                for (int i = 0; i < Convert.ToInt32(Patern_min.Text); i++)
                {
                    litera = (char)losuj.Next(65, 65 + Convert.ToInt32(Alfabet.Text));
                    PT    += litera;
                }

                for (int u = Convert.ToInt32(Patern_min.Text); u < Convert.ToInt32(Patern_Max.Text); u = u + 10)
                {
                    for (int i = PT.Length; i < u; i++)
                    {
                        litera = (char)losuj.Next(65, 65 + Convert.ToInt32(Alfabet.Text));
                        PT    += litera;
                    }

                    chart2.Update();

                    if (KMP_box.Checked)
                    {
                        var watchKMP = System.Diagnostics.Stopwatch.StartNew();
                        txt.KMPSearch(PT);
                        watchKMP.Stop();
                        chart2.Series["KMP"].Points.AddXY((double)u, Convert.ToInt32(watchKMP.ElapsedTicks));
                    }
                    if (sunday_box.Checked)
                    {
                        var watchSunday = System.Diagnostics.Stopwatch.StartNew();
                        txt.SundaySeartch(PT);
                        watchSunday.Stop();
                        chart2.Series["Sunday"].Points.AddXY((double)u, Convert.ToInt32(watchSunday.ElapsedTicks));
                    }
                    if (BM.Checked)
                    {
                        BMSearch.BoyerMoore BM = new BMSearch.BoyerMoore(textBox1.Text);
                        txt.preBM(PT);
                        var watchBM = System.Diagnostics.Stopwatch.StartNew();
                        txt.BMSeartch();
                        watchBM.Stop();
                        chart2.Series["BM"].Points.AddXY((double)u, Convert.ToInt32(watchBM.ElapsedTicks));
                    }
                }
                PT.Remove(0);
                T.Remove(0);
            }
        }