/** method: main, the starting point for this class's tests * inputs: a String array not being used right now * outputs: none */ /* * NOTE: this will not work unless all of the methods called are written! * * BUT, it might be useful to paste one or two tests at a time... */ public static void main(String[] args) { System.out.println("Starting main..."); /* tests for the constructors */ OpenList greet1 = new OpenList( "Hello", OpenList.emptyList ); OpenList greet2 = new OpenList( "Hey", greet1 ); System.out.println(greet1); // should be ["Hello"] System.out.println(greet2); // should be ["Hey", "Hello"] /* more tests for the constructors */ OpenList numericStrings = OpenList.emptyList; System.out.println("numericStrings is " + numericStrings); // should be [] for (int i=0 ; i<5 ; ++i) { numericStrings = new OpenList( i , numericStrings ); } System.out.println("numericStrings is " + numericStrings); // should be [4, 3, 2, 1, 0] /* Be sure to include tests for all of your methods here !! */ String s1 = "cons"; OpenList e = OpenList.emptyList; OpenList staticConsTest = OpenList.cons( s1, OpenList.cons( "works!", e ) ); System.out.println("staticConsTest is " + staticConsTest); OpenList nonstaticConsTest = e.cons( "work!" ).cons( s1 ); System.out.println("nonstaticConsTest is " + nonstaticConsTest); OpenList ol1 = nonstaticConsTest.cons( "another first!" ); int nonstaticLengthTest = ol1.length(); System.out.println("the list " + ol1 + " has length " + nonstaticLengthTest); System.out.println("the list " + ol1 + " has length " + OpenList.length( ol1 )); System.out.println("(static) the first of " + ol1 + " is " + OpenList.first( ol1 )); System.out.println("(nonstatic) the first of " + ol1 + " is " + ol1.first()); //System.out.println("\n(nonstatic) the first of " + e + " is " + e.first()); System.out.println("(static) the rest of " + ol1 + " is " + OpenList.rest( ol1 )); System.out.println("(nonstatic) the rest of " + ol1 + " is " + ol1.rest()); //System.out.println("\n(nonstatic) the rest of " + e + " is " + e.rest()); OpenList fates = OpenList.list( "Clotho", "Lachesis", "Atropos" ); System.out.println("A fateful list: " + fates ); OpenList setaf = fates.reverse(); System.out.println("Another fateful list: " + setaf ); OpenList setaf2 = OpenList.reverse(fates); System.out.println("Another fateful list: " + setaf2 ); OpenList chiasmicFates = fates.append(setaf); OpenList chiasmicFates2 = OpenList.append(fates,setaf); System.out.println("chiasmicFates: " + chiasmicFates ); System.out.println("chiasmicFates2: " + chiasmicFates2 ); OpenList associationList1 = OpenList.list( OpenList.list( "A", "alpha" ), OpenList.list( "B", "bravo" ), OpenList.list( "C", "charlie" ) ); System.out.println("associationList1: " + associationList1 ); System.out.println("assoc( A, AL1 ): " + associationList1.assoc( "A" ) ); System.out.println("assoc( A, AL1 ): " + OpenList.assoc( "A", associationList1 ) ); System.out.println("assoc( D, AL1 ): " + associationList1.assoc( "D" ) ); System.out.println("assoc( D, AL1 ): " + OpenList.assoc( "D", associationList1 ) ); OpenList halfAlph = OpenList.list( "A", "C", "D" ).append( OpenList.list( "H", "I", "K" ) ); OpenList halfAlph2 = OpenList.list( "B", "E", "F" ).append( OpenList.list( "G", "J", "L" ) ); System.out.println("halfAlph: " + halfAlph ); System.out.println("halfAlph2: " + halfAlph2 ); OpenList m1 = OpenList.merge( halfAlph, halfAlph2 ); OpenList m2 = halfAlph.merge( halfAlph2 ); System.out.println("m1: " + m1 ); System.out.println("m2: " + m2 ); OpenList biglist = OpenList.anylist( "Z", "Y", "X", "W", "V" ); System.out.println("biglist: " + biglist ); OpenList bunchOLists = OpenList.list( biglist, m1, chiasmicFates ); System.out.println("bunchOLists: " + bunchOLists ); System.out.println("duperreverse of bunchOLists: " + bunchOLists.duperreverse() ); System.out.println("first4 of m1: " + OpenList.firstN( m1, 4 ) ); System.out.println("final4 of m1: " + OpenList.finalN( m1, 4 ) ); OpenList tosort = halfAlph.append( halfAlph2.cons("Z") ); System.out.println("tosort: " + tosort ); OpenList[] halves = OpenList.split( tosort ); System.out.println("first half of tosort: " + halves[0] ); System.out.println("second half of tosort: " + halves[1] ); OpenList sorted = OpenList.mergesort( tosort ); System.out.println("sorted: " + sorted ); System.out.println("Finishing main..."); } // end of main