public void add(T item) {
   QueueNode<T> t = new QueueNode<T>(item);
   if (last != null) {
     last.next = t;
   }
   last = t;
   if (first == null) {
     first = last;
   }
 }
Example #2
0
 public void add(T item) {
   QueueNode<T> t = new QueueNode<T>(item);
   if (last != null) {
     System.out.println("before last: " + last.data + " next: " + last.next);
     last.next = t; // making the connection
     System.out.println("after last: " + last.data + " next: " + last.next);
   }
   last = t; // setting last eliment
   System.out.println("again last: " + last.data + " next: " + last.next);
   if (first == null) {
     first = last;
   }
 }
  public void add(T item) {
    if (size == MAX_NODES) {
      System.err.println("QUEUE FULL");
      return;
    }

    QueueNode<T> t = new QueueNode<T>(item);
    if (last != null) {
      last.next = t;
    }

    last = t;
    if (first == null) {
      first = last;
    }

    size++;
  }