Beispiel #1
0
 /**
  * Returns a string representation of the list
  *
  * @return s string representation of the list
  */
 @Override
 public String toString() {
   String s = "[ ";
   DLNode<E> v = self.header.getNext();
   while (v != self.trailer) {
     s += v.getElement();
     v = v.getNext();
     if (v != self.trailer) {
       s += ", ";
     }
   }
   s += " ]";
   return s;
 }
Beispiel #2
0
 /**
  * Returns the node after the given node v. An error occurs if v is the trailer
  *
  * @param v the current node we are looking to get the next node of
  */
 public DLNode<E> getNext(DLNode<E> v) throws IllegalArgumentException {
   if (v == self.trailer) {
     throw new IllegalArgumentException("Cannot move forward past the trailer of the list");
   }
   return v.getNext();
 }