Esempio n. 1
0
        public void Delete(T data)
        {
            DuplexPoint <T> current = Head;

            while (current != null)
            {
                if (current.Data.Equals(data))
                {
                    if (Head.Previous != null)
                    {
                        current.Previous.Next = current.Next;
                        current.Next.Previous = current.Previous;
                        Count--;
                        return;
                    }
                    else
                    {
                        Head          = current.Next;
                        Head.Previous = null;
                        Count--;
                        return;
                    }
                }

                current = current.Next;
            }

            Console.WriteLine("Элемент не найден!");
        }
Esempio n. 2
0
        public void Add(T data)
        {
            DuplexPoint <T> item = new DuplexPoint <T>(data);

            if (Count == 0)
            {
                SetHeadAndTail(item);
            }
            else
            {
                Tail.Next     = item;
                item.Previous = Tail;
                Tail          = item;
                Count++;
            }
        }
Esempio n. 3
0
        public void DeleteEven()
        {
            DuplexPoint <T> current = Head;
            int             check   = 1;

            if (current == null)
            {
                Console.WriteLine("Список пуст!");
            }
            while (current != null)
            {
                if (check % 2 == 0)
                {
                    current.Previous.Next = current.Next;
                    current.Next.Previous = current.Previous;
                    Count--;
                }
                check++;
                current = current.Next;
            }
            Console.WriteLine("Элементы были удалены!");
            return;
        }
Esempio n. 4
0
 public DuplexPoint(T data)
 {
     Data     = data;
     Next     = null;
     Previous = null;
 }
Esempio n. 5
0
 public DuplexPoint()
 {
     Next     = null;
     Previous = null;
     Data     = default(T);
 }
Esempio n. 6
0
 private void SetHeadAndTail(DuplexPoint <T> item)
 {
     Head  = item;
     Tail  = item;
     Count = 1;
 }
Esempio n. 7
0
        public LinkedList(T data)
        {
            DuplexPoint <T> item = new DuplexPoint <T>(data);

            SetHeadAndTail(item);
        }