
import jgraspvex.LinkedList;

/**
 * LinkedListExample - This example is intended to illustrate
 * the capabilities of the Presentation Structure Identifier
 * rendering of a linked list structure in the viewer canvas.  
 * 
 * Click the "Run in Canvas" button on the toolbar. Then on 
 * the canvas window, click the "Play" button. Regulate the 
 * speed with the "Delay" slider.
 * 
 * To end the program, click the "Stop" button on the canvas 
 * or click the "End" button on the Run I/O tab.   
 *
 * To create your own canvas, click the "Pause" button on the
 * canvas.  Then on the Debug tab click the "Open Canvas" button.
 * Click the "Step" and Step-in" buttons as needed until you 
 * see objects and primitives of interest in the Variables tab 
 * and then drag them onto the canvas. Arrange the viewers and 
 * click the "Play" button.
 */
public class LinkedListExample {


   public static void main(String[] args) {
    
      while (true) {
         LinkedList list = new LinkedList();
         for (int i = 0; i < 2; i++) {
            System.out.println("Add: " + i);
            list.add(String.valueOf(i));
         }
         
         System.out.println("Add: " + null);
         list.add(null);
                        
         for (int i = 2; i >= 0; i--) {
            System.out.println("Insert: x" + i + " at position " + i);
            list.add(i, "x" + i);
         }
      
         for (int i = 0; i < 2; i++) {
            System.out.println("Remove element at position: " + i);
            list.remove(i);                
         }
      }
   }
}