public StringBuilder PrintNodeList() { DoubleNode n = Head; StringBuilder Sb = new StringBuilder(); while (n != null) { Sb.AppendFormat(n.Value.ToString()); n = n.Next; } return(Sb); }
/// <summary> /// Add the integer value to the end of the list. /// </summary> /// <param name="node"></param> public void AddLast(DoubleNode node) { if (CountOfNodes == 0) { Head = node; } else { Tail.Next = node; node.Previous = Tail; } Tail = node; CountOfNodes++; }
/// <summary> /// Returns true if the list contains the specified item, otherwise returns false. /// </summary> /// <param name="number"></param> /// <returns></returns> public bool Contains(int number) { DoubleNode n = Head; while (n.Next != null) { if (n.Value == number) { return(true); } n = n.Next; } return(false); }
/// <summary> /// Adds the integer value to the start of the list. /// </summary> /// <param name="node"></param> public void AddFirst(DoubleNode node) { DoubleNode temp = Head; Head = node; Head.Previous = null; Head.Next = temp; CountOfNodes++; if (CountOfNodes == 1) { Tail = Head; } }
/// <summary> /// Constructor of a new node that receive integer value. /// </summary> /// <param name="value"></param> public DoubleNode(int value) { Value = value; Next = null; Previous = null; }