Example #1
0
 public void add(int new_value)
 {
     if (size == 0)
     {
         this.head = new MyListNode(new_value);
         this.tail = this.head;
     }
     else
     {
         this.tail.next = new MyListNode(new_value);
         this.tail      = this.tail.next;
     }
     this.size++;
 }
Example #2
0
 public void add(int new_value)
 {
     if (size == 0)
     {
         this.head = new MyListNode(new_value);
         this.tail = this.head;
     }
     else
     {
         this.tail.next = new MyListNode(new_value);
         this.tail = this.tail.next;
     }
     this.size++;
 }
Example #3
0
        public void print()
        {
            MyListNode cur = this.head;

            if (this.size == 0)
            {
                System.Console.WriteLine("List is empty!");
            }
            else
            {
                while (cur != null)
                {
                    System.Console.WriteLine(cur.value);
                    cur = cur.next;
                }
            }
        }
Example #4
0
 public MyList()
 {
     size = 0;
     head = null;
     tail = null;
 }
Example #5
0
 public MyListNode(int? value = null, MyListNode next = null)
 {
     this.value = value;
     this.next = next;
 }
Example #6
0
 public MyList()
 {
     size = 0;
     head = null;
     tail = null;
 }
Example #7
0
 public MyListNode(int?value = null, MyListNode next = null)
 {
     this.value = value;
     this.next  = next;
 }