Пример #1
0
        public void Remove(LinkedListNode2 <T> remove)
        {
            if (remove == null)
            {
                return;
            }

            for (LinkedListNode2 <T> node = First; node != null; node = node.Next)
            {
                if (node == remove)
                {
                    if (node == First)
                    {
                        First = node.Next;
                    }
                    if (node == Last)
                    {
                        Last = node.Previous;
                    }

                    if (node.Previous != null)
                    {
                        node.Previous.Next = node.Next;
                    }
                    if (node.Next != null)
                    {
                        node.Next.Previous = node.Previous;
                    }
                }
            }
        }
Пример #2
0
        private void AddRoot(LinkedListNode2 <T> node)
        {
            if (node == null)
            {
                throw new ArgumentNullException();
            }

            First         = node;
            Last          = node;
            node.Next     = null;
            node.Previous = null;
        }
Пример #3
0
        public void AddFirst(LinkedListNode2 <T> node)
        {
            if (node == null)
            {
                throw new ArgumentNullException();
            }

            if (First == null)
            {
                AddRoot(node);
            }
            else
            {
                node.Previous  = null;
                node.Next      = First;
                First.Previous = node;
                First          = node;
            }
        }
Пример #4
0
 public LinkedList2()
 {
     First = null;
     Last  = null;
 }