Ejemplo n.º 1
0
        public StringBuilder PrintNodeList()
        {
            DoubleNode    n  = Head;
            StringBuilder Sb = new StringBuilder();

            while (n != null)
            {
                Sb.AppendFormat(n.Value.ToString());
                n = n.Next;
            }
            return(Sb);
        }
Ejemplo n.º 2
0
 /// <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++;
 }
Ejemplo n.º 3
0
        /// <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);
        }
Ejemplo n.º 4
0
        /// <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;
            }
        }
Ejemplo n.º 5
0
 /// <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;
 }