Ejemplo n.º 1
0
        // Make a list of random items.
        private void makeItemsButton_Click(object sender, EventArgs e)
        {
            int    numItems = int.Parse(numItemsTextBox.Text);
            int    minimum  = int.Parse(minimumTextBox.Text);
            int    maximum  = int.Parse(maximumTextBox.Text);
            Random rand     = new Random();

            // Delete the previous list if there is one.
            //(This isn't necessary in C#.)

            // Add cells.
            ValueCell newTop = null;

            for (int i = 0; i < numItems; i++)
            {
                ValueCell newCell = new ValueCell();
                newCell.Value = rand.Next(minimum, maximum);
                newCell.Next  = newTop;
                newTop        = newCell;
            }

            // Make a new sentinel.
            TopCell = new ValueCell()
            {
                Value = 0, Next = newTop
            };

            // Make a copy.
            CopyTopCell = TopCell.CopyList();

            // Display the list.
            DisplayList();
        }
Ejemplo n.º 2
0
 // Reset the list to the original insorted values.
 private void resetButton_Click(object sender, EventArgs e)
 {
     TopCell = CopyTopCell.CopyList();
     DisplayList();
 }