Example #1
0
 bool IEnumerator.MoveNext()
 {
     if (Node == ListR.Last)
     {
         return(false);
     }
     if (Node == null)
     {
         Node = ListR.First;
     }
     else
     {
         Node = Node.Next;
     }
     return(true);
 }
Example #2
0
        public void AddFirst(T value)
        {
            var newNode = new MyLinkedListNode <T>(this, value);

            if (this.First == null)
            {
                this.first = newNode;
                this.last  = newNode;
            }
            else
            {
                this.First.previous = newNode;
                newNode.next        = this.First;
                this.first          = newNode;
            }
            this.count++;
        }
Example #3
0
        public void Remove(T value)
        {
            var node = this.First;

            while ((node != null) && !node.Value.Equals(value))
            {
                node = node.Next;
            }
            if (node == null)
            {
                throw new ArgumentOutOfRangeException("node null", node = null, MessageError);
            }
            if ((node == this.First) && (node == this.Last))
            {
                this.first = null;
                this.last  = null;
            }
            else
            if (node == this.First)
            {
                var temp = this.First.Next;
                this.First.Next.previous = null;
                this.First.next          = null;
                this.first = temp;
            }
            else
            if (node == this.Last)
            {
                var temp = this.Last.Previous;
                this.Last.Previous.next = null;
                this.Last.previous      = null;
                this.last = temp;
            }
            else
            if ((node != this.First) && (node != this.Last))
            {
                node.Previous.next = node.Next;
                node.Next.previous = node.Previous;
                node.previous      = null;
                node.next          = null;
            }
            this.count--;
        }
Example #4
0
        public void AddAfter(MyLinkedListNode <T> node, T value)
        {
            if (node.Ovner != this)
            {
                throw new ArgumentOutOfRangeException("ovne False", node = null, MessageError);
            }

            if (node == this.last)
            {
                this.AddLast(value);
                return;
            }
            var newNode  = new MyLinkedListNode <T>(this, value);
            var nodeNext = node.Next;

            node.next         = newNode;
            newNode.previous  = node;
            nodeNext.previous = newNode;
            newNode.next      = nodeNext;

            this.count++;
        }
Example #5
0
 void IEnumerator.Reset()
 {
     Node = null;
 }
Example #6
0
 void IDisposable.Dispose()
 {
     Node  = null;
     ListR = null;
 }
Example #7
0
 public MyLinkedListEnum(MyLinkedList <T> List)
 {
     Node  = List.First.Previous;
     ListR = List;
 }