Пример #1
0
 public void insertFirst(int newItem)
 {
     if (head == null)
     {
         head = new Node(newItem);
     }
     else
     {
         Node t = new Node(newItem);
         t.next = head;
         head = t;
     }
 }
Пример #2
0
 public void insertLast(int newItem)
 {
     if (head == null)
     {
         head = new Node(newItem);
     }
     else
     {
         // traverse to the last and insert
         Node t = head;
         while (t.next != null)
         {
             t = t.next;
         }
         t.next = new Node(newItem);
     }
 }
Пример #3
0
 public Node(int d)
 {
     this.data = d;
     next = null;
     arbitrary = null;
 }
Пример #4
0
 public LL()
 {
     head = null;
 }