Esempio n. 1
0
        // добавление нового элемента
        public void Add(string inf)
        {
            if (count == 0)
            {
                head = new MyNode(inf, null);

            }
            else
            {
                MyNode p = GetNode(count - 1);
                MyNode tmp = new MyNode(inf, null);
                p.next = tmp;
            }
            count++;
        }
Esempio n. 2
0
 // Удалить по индексу
 public void Delete(int index)
 {
     MyNode p;
     if (index == count)
     {
         p = GetNode(index - 1);
         p.next = null;
     }
     else
     {
         if (index != 0)
         {
             p = GetNode(index - 1);
             p.next = p.next.next;
         }
         else
             head = head.next;
     }
     count--;
 }
Esempio n. 3
0
        public MyNode head; // голова списка

        #endregion Fields

        #region Constructors

        // Конструктор
        public MyList()
        {
            head = null;
            count = 0;
        }
Esempio n. 4
0
 // конструктор
 public MyNode(string inf, MyNode next)
 {
     this.inf = inf;
     this.next = next;
 }