예제 #1
0
 public void insertLast(ListNode x) {
   if (front == null) {
     front = back = x;
     size++;
   } else {
     front.setNext(x);
     front = x;
     size++;
   }
 }
예제 #2
0
 public void insertFirst(ListNode x) {
   if (back == null) {
     front = back = temp = x;
     size++;
   } else {
     x.setNext(back);
     back = x;
     size++;
   }
 }