private void createAmountNumbers()
        {
            string result = "100";

            foreach (Control control in this.gbRange.Controls)
            {
                if (control is RadioButton)
                {
                    RadioButton myRadio = control as RadioButton;
                    if (myRadio.Checked)
                    {
                        result = myRadio.Text;
                    }
                }
            }

            randomNumbers myRnd = new randomNumbers();

            int[] elements = myRnd.arrayElements(int.Parse(result));
            foreach (int i in elements)
            {
                myList.insert_node(i);
            }
            listBoxElements.DataSource = null;
            List <int> _items = new List <int>();

            foreach (int items in elements)
            {
                _items.Add(items);
            }
            listBoxElements.DataSource = _items;
        }
        private void btnCreateList_Click(object sender, EventArgs e)
        {
            myHash = new simple_hash_function();
            listBox2.DataSource = null;
            string result = "100";

            foreach (Control control in this.groupBox1.Controls)
            {
                if (control is RadioButton)
                {
                    RadioButton myRadio = control as RadioButton;
                    if (myRadio.Checked)
                    {
                        result = myRadio.Text;
                    }
                }
            }
            label1.Text = "List of " + result + " numbers created ";

            randomNumbers myRnd  = new randomNumbers();
            List <int>    _items = new List <int>();

            foreach (int items in myRnd.arrayElements(int.Parse(result)))
            {
                _items.Add(items);
            }
            listBox1.DataSource = _items;
        }
Ejemplo n.º 3
0
        private void btnFind_Click(object sender, EventArgs e)
        {
            validations myVal = new validations();

            if (myVal.intValidation(txtFind.Text.ToString()))
            {
                string result = "100";

                foreach (Control control in this.groupBox1.Controls)
                {
                    if (control is RadioButton)
                    {
                        RadioButton myRadio = control as RadioButton;
                        if (myRadio.Checked)
                        {
                            result = myRadio.Text;
                        }
                    }
                }

                randomNumbers     myRnd      = new randomNumbers();
                int[]             myElements = myRnd.arrayElements(int.Parse(result));
                Simple_merge_sort mySort     = new Simple_merge_sort();
                listBox2.DataSource = myElements.ToArray();
                mySort.sort(myElements);
                List <string> _items = new List <string>(); // <-- Add this

                _items = new List <string>();               // <-- Add this
                foreach (int i in myElements)
                {
                    _items.Add(i.ToString());
                }
                listBox1.DataSource = _items;

                SimpleBinarySearch myBinarySearch = new SimpleBinarySearch();
                if (myBinarySearch.find(myElements, int.Parse(txtFind.Text)))
                {
                    int myIndex = listBox1.FindString(txtFind.Text);
                    listBox1.SetSelected(myIndex, true);
                    MessageBox.Show("Value  Found: " + txtFind.Text.ToString(), "Error", MessageBoxButtons.OK);
                }
                else
                {
                    MessageBox.Show("Value Not Found", "Error", MessageBoxButtons.OK);
                }
            }
            else
            {
                MessageBox.Show("Must type a enter value, thx", "Error", MessageBoxButtons.OK);
            }
        }
        private void fillListBox()
        {
            Random randomGenerator = new Random();


            List <randomNumbers> lstRandVariables = new List <randomNumbers>();

            for (int i = 0; i < 100; i++)
            {
                randomNumbers myRand = new randomNumbers();
                myRand.irId = staticVariables.irGlobalId;
                staticVariables.irGlobalId++;
                myRand.irRandNumber = Convert.ToUInt64(randomGenerator.Next());
                lstRandVariables.Add(myRand);
            }

            foreach (var vrElement in lstRandVariables)
            {
                listBoxRands.Items.Add($"{vrElement.irId}\t\t{vrElement.irRandNumber.ToString("N0")}");
            }
        }
        private void pupulate()
        {
            string result = "100";

            foreach (Control control in this.groupBox1.Controls)
            {
                if (control is RadioButton)
                {
                    RadioButton myRadio = control as RadioButton;
                    if (myRadio.Checked)
                    {
                        result = myRadio.Text;
                    }
                }
            }
            label1.Text = "Unsorted List of " + result;
            label2.Text = "Sorted List of " + result;

            randomNumbers myRnd = new randomNumbers();

            elements = myRnd.arrayElements(int.Parse(result));
        }