import java.io.PrintWriter; import java.io.BufferedReader; import java.io.InputStreamReader; /** * Some experiments to better understand linked lists */ public class TestYDLLI { public static void main(String[] args) throws Exception { // Prepare input and screenput. BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in)); PrintWriter screen = new PrintWriter(System.out, true); // Create a list for simple testing. YDLL ll = new YDLL(); ll.addToEnd("a"); ll.addToEnd("b"); ll.addToEnd("c"); ll.addToEnd("d"); ll.addToEnd("e"); ll.addToEnd("f"); ll.addToEnd("g"); screen.println("List is " + ll); ListIterator it = ll.newIterator(); screen.println("The iterator is now at " + it.current()); it.advance(); screen.println("After advancing, iterator is now at " + it.current()); it.delete(); screen.println("After deletion, list is " + ll); screen.println("The iterator is now at " + it.current()); it.insertBefore("x"); screen.println("After inserting x, list is " + ll); screen.println("The iterator is now at " + it.current()); it.delete(); screen.println("After deletion, list is " + ll); screen.println("The iterator is now at " + it.current()); it.insertAfter("y"); screen.println("After inserting y, list is " + ll); screen.println("The iterator is now at " + it.current()); it.find("g"); screen.println("Testing find 'g'. The iterator is now at " + it.current()); it.replace("z"); screen.println("After replacing the current value with 'z'. The list is now " + ll); screen.println("The iterator is now at " + it.current()); screen.println("Are we still in the list? " + it.isValid()); //Testing a sorting algorithm screen.println("Testing a sorting algorithm."); YDLL lll = new YDLL(); lll.addToEnd("5"); lll.addToEnd("8"); lll.addToEnd("9"); lll.addToEnd("1"); lll.addToEnd("2"); lll.addToEnd("5"); lll.addToEnd("8"); lll.addToEnd("7"); screen.println("Trying to sort " + lll); screen.println("I am completely stuck cuz my program is not working properly...time to go to sleep...more to life than CS! Have to stay in good health."); // That's it, we're done. System.exit(0); } // main(String[]) } // class TestYDLLI