public void CopyTo(T[] array, int arrayIndex) { LinkedNode <T> temp = Head; while (temp != null) { array[arrayIndex++] = Head.Data; temp = temp.Next; } }
public void print( ) { LinkedNode <T> temp = Head; while (temp != null) { Console.WriteLine(temp.Data); temp = temp.Next; } }
public void removeFirst( ) { if (Head != null) { Head = Head.Next; if (Head == null) { Tail = null; } } }
public void addFirst(LinkedNode <T> node) { LinkedNode <T> temp = Head; Head = node; Head.Next = temp; if (temp == null) { Tail = Head; } }
public IEnumerator <T> GetEnumerator( ) { LinkedNode <T> current = Head; while (current != null) { yield return(current.Data); current = current.Next; } }
public void addLast(LinkedNode <T> node) { if (Head == null) { Head = node; } else { Tail.Next = node; } Tail = node; }
public bool Contains(T item) { LinkedNode <T> temp = Head; while (temp != null && !temp.Data.Equals(item)) { temp = temp.Next; } if (temp != null) { return(true); } return(false); }
public void removeLast( ) { if (Tail != null) { if (Head.Next == null) { Tail = null; Head = null; } else { LinkedNode <T> temp = Head; while (temp.Next != Tail) { temp = temp.Next; } temp.Next = null; Tail = temp; } } }
public LinkedList( ) { Head = null; Tail = null; }