//public T Find(T item) //{ // MyList<T> temp = this; // while (temp != null) // { // if (temp.Item != item) // temp = temp.Next; // else // return temp.Item; // } // return null; //} #region IEnumerable<T> Members public IEnumerator <T> GetEnumerator() { OnceLinkedList <T> temp = this; while (temp != null) { yield return(temp.Item); temp = temp.Next; } }
/// <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); } }
/// <summary> /// Replace Next node with new node. /// </summary> /// <param name="item">Item to add to new node.</param> /// <returns></returns> private OnceLinkedList <T> Append(T item) { Next = new OnceLinkedList <T>(item); return(Next); }