public bool Remove(T element) { if (this.root == null) { return(false); } var currentRoot = this.root; if (currentRoot.Element.CompareTo(element) == 0) { this.root = currentRoot.NextElement; return(true); } while (currentRoot.NextElement != null) { var next = currentRoot.NextElement; if (next.Element.CompareTo(element) == 0) { currentRoot.NextElement = next.NextElement; return(true); } currentRoot = currentRoot.NextElement; } return(false); }
public void Add(T element) { if (this.root == null) { this.root = new MyGenericLinkedListNode <T>(element); return; } var currentRoot = this.root; while (currentRoot.NextElement != null) { currentRoot = currentRoot.NextElement; } currentRoot.NextElement = new MyGenericLinkedListNode <T>(element); }
public MyGenericLinkedList(T root) { this.root = new MyGenericLinkedListNode <T>(root); }