Esempio n. 1
0
        //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;
            }
        }
Esempio n. 2
0
 /// <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);
     }
 }
Esempio n. 3
0
 /// <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);
 }