public void RemoveFirst() { try { if (Head == null) { Exception ex = new Exception("Can not remove node from Empty list"); throw ex; } else { if (Head == Tail) { Head = Tail = null; } else { Head = Head.Next; } } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public void AddFirst(DoubleLinkedlistNode <T> node) { if (Head == null) { Head = Tail = node; } else { node.Next = Head; Head.Prev = node; Head = node; } Count++; }
public void AddLast(DoubleLinkedlistNode <T> node) { if (Head == null) { Head = Tail = node; } else { DoubleLinkedlistNode <T> temp = Tail; Tail = node; node.Prev = temp; temp.Next = node; /*Below is my alternate implementation*/ //node.Prev = Tail; //Tail.Next = node; //Tail = node; } }
public void AddLast(T value) { DoubleLinkedlistNode <T> node = new DoubleLinkedlistNode <T>(value); AddLast(node); }