bool IEnumerator.MoveNext() { if (Node == ListR.Last) { return(false); } if (Node == null) { Node = ListR.First; } else { Node = Node.Next; } return(true); }
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++; }
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--; }
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++; }
void IEnumerator.Reset() { Node = null; }
void IDisposable.Dispose() { Node = null; ListR = null; }
public MyLinkedListEnum(MyLinkedList <T> List) { Node = List.First.Previous; ListR = List; }