예제 #1
0
        public static void LinkedList()
        {
            TrialLinkedList <Trial> list = new TrialLinkedList <Trial>();

            list.Beg = list.MakeList(5);
            Point <Trial> beg    = list.Beg;
            int           choice = -1;

            while (choice != 4)
            {
                Console.WriteLine("1. Печать");
                Console.WriteLine("2. Добавление элемента после заданного");
                Console.WriteLine("3. Удалить список из памяти");
                Console.WriteLine("4. Назад");

                bool ok = int.TryParse(Console.ReadLine(), out choice);
                if (!ok)
                {
                    do
                    {
                        Console.WriteLine("Проверьте правильность ввода");
                        ok = int.TryParse(Console.ReadLine(), out choice);
                    } while (!ok || choice < 0 || choice > 4);
                }

                switch (choice)
                {
                case 1:
                    Console.Clear();
                    list.ShowList(list.Beg);
                    break;

                case 2:
                    Console.WriteLine("Введите номер элемента, после которого необходимо добавить элемент");
                    int num;
                    ok = int.TryParse(Console.ReadLine(), out num);
                    if (!ok)
                    {
                        do
                        {
                            Console.WriteLine("Проверьте правильность ввода");
                            ok = int.TryParse(Console.ReadLine(), out num);
                        } while (!ok || num < 0);
                    }
                    list.AddPoint(beg, num, rnd);
                    break;

                case 3:
                    list.Beg = null;
                    Console.WriteLine("Удаление выполнено");
                    break;

                case 4:
                    choice = 4;
                    Console.Clear();
                    break;
                }
            }
        }
예제 #2
0
 public MyStack(MyStack <T> c) //служит для создания коллекции, которая инициализируется элементами
 //и емкостью коллекции, заданной параметром с.
 {
     TrialLinkedList <T> newList = c.StackList;
 }
예제 #3
0
 public MyStack(int capacity) // создает пустую коллекцию с начальной емкостью, заданной параметром capacity.
 {
     StackList = new TrialLinkedList <T>(capacity);
 }
예제 #4
0
 public MyStack() //предназначен для создания пустой коллекции.
 {
     StackList = new TrialLinkedList <T>();
 }
예제 #5
0
 public TrialLinkedList(TrialLinkedList <T> list)
 {
     Beg = list.Beg;
 }