Exemple #1
0
        public static List <ParallelSearchResult> ArrayThreadTask(object paramObj)
        {
            DamLev L1 = new DamLev();
            ParallelSearchThreadParam param = (ParallelSearchThreadParam)paramObj;

            string wordUpper = param.wordPattern.Trim().ToUpper();

            List <ParallelSearchResult> Result = new List <ParallelSearchResult>();

            foreach (string str in param.tempList)
            {
                int dist = L1.Distance(str.ToUpper(), wordUpper);

                if (dist <= param.maxDist)
                {
                    ParallelSearchResult temp = new ParallelSearchResult()
                    {
                        word      = str,
                        dist      = dist,
                        ThreadNum = param.ThreadNum
                    };
                    Result.Add(temp);
                }
            }
            return(Result);
        }
Exemple #2
0
        private void Search_button_Click(object sender, RoutedEventArgs e)
        {
            string word = this.Inputwords.Text.Trim();


            if (!string.IsNullOrWhiteSpace(word) && list.Count > 0 && word != "Введите слово для поиска")
            {
                string wordUpper = word.ToUpper();
                DamLev L         = new DamLev();

                List <string> tList = new List <string>();
                Stopwatch     t     = new Stopwatch();
                t.Start();

                int maxRange = Int32.Parse(this.Max_range.Text.Trim());

                foreach (string str in list)
                {
                    if (L.Distance(str, wordUpper) <= maxRange)
                    {
                        tList.Add(str);
                    }
                }
                t.Stop();
                this.Anothertimer.Text = t.Elapsed.ToString();

                this.found_words.Items.Clear();

                foreach (string str in tList)
                {
                    this.found_words.Items.Add(str);
                }
            }
            else
            {
                MessageBox.Show("Видимо вы не выбрали файл");
            }
        }