コード例 #1
0
 @Override
 public String toString() {
   String result = "MyLinkedList{";
   LLNode<E> probe = head;
   for (int i = 0; i < this.size; i++) {
     result += probe + " ";
     probe = probe.getNext();
   }
   result += '}';
   return result;
 }
コード例 #2
0
 // Return the next node based on the referenceNode
 private LLNode<E> getNext(LLNode<E> referenceNode) {
   if (referenceNode == tail) {
     throw new BoundaryViolationException("Reference cannot be equal to tail");
   }
   return referenceNode.getNext();
 }