/// <summary> /// Append new Item to end of list. /// </summary> /// <param name="item"></param> /// <returns></returns> public OnceLinkedList <T> AppendToLast(T item) { if (Next != null) { return(Next.AppendToLast(item)); } else { return(Append(item)); } }
/// <summary> /// Returns list containing all previous nodes and new node. /// </summary> /// <param name="list">List containing items that will be in new list.</param> /// <param name="item">Item od new node.</param> /// <returns></returns> public static OnceLinkedList <T> Append(ref OnceLinkedList <T> list, T item) { if (list != null) { return(list.AppendToLast(item)); } else { list = new OnceLinkedList <T>(item); return(list); } }