Esempio n. 1
0
 public void AddToEnd(int data)
 {
     if (headNode == null)
     {
         headNode = new Node(data);
     }
     else
     {
         headNode.AddToEnd(data);
     }
 }
Esempio n. 2
0
 public void AddToEnd(int data)
 {
     if (next == null)
     {
         next = new Node(data);
     }
     else
     {
         next.AddToEnd(data);
     }
 }
Esempio n. 3
0
 public void AddToEnd(int data)
 {
     if (headNode == null)
     {
         headNode = new Node(data);
     }
     else
     {
         //using recursion, method is calling itself until the condition is met
         headNode.AddToEnd(data);
     }
 }
Esempio n. 4
0
 public void AddToEnd(int data)
 {
     // In this case we know that this is the end of the list, so we just add a new Node!
     if (next == null)
     {
         next = new Node(data);
     }
     else
     {
         // recursive call (passa the responsibility down to the chain, until "next" == null)!
         next.AddToEnd(data);
     }
 }