public LinkedList(IEnumerable <T> list) { this.headGuard = new LinkedNode <T>(default(T)); if (list != null) { var p = this.headGuard; foreach (T item in list) { p.Next = new LinkedNode <T>(item); p = p.Next; ++this.length; } } }
public LinkedNode <T> InsertAfter(LinkedNode <T> node, T item) { if (node == null) { throw new ArgumentNullException("node is null"); } var newNode = new LinkedNode <T>(item) { Next = node.Next }; node.Next = newNode; this.length++; return(newNode); }
private LinkedNode <T> ReverseHandler(LinkedNode <T> head) { if (head == null) { return(null); } if (head.Next == null) { this.headGuard.Next = head; } else { var remainHead = this.ReverseHandler(head.Next); remainHead.Next = head; } return(head); }
public LinkedList() { this.headGuard = new LinkedNode <T>(default(T)); }