import rpi.goldsd.container.*; import rpi.goldsd.shape.*; public class TableTest { public static void main( String[] args ) { Int key1 = new Int( 47 ); Int key2 = new Int( 36 ); Int key3 = new Int( 137 ); Table T = new Table( 101 ); if ( T.isEmpty() ) System.out.println( "Table is initially empty." ); T.add( key1, new Rect( 10, 10, 30, 40 ) ); T.add( key2, new Circle( 10, 20, 5 ) ); if ( T.isEmpty() ) System.out.println( "FATAL ERROR -- TABLE IS EMPTY!" ); T.add( key3, new Rect( 25, 30, 5, 5 ) ); T.add( new Int( 541 ), key1 ); System.out.println( "Table size is " + T.getSize() + "." ); System.out.println( T ); System.out.println( "true == " + T.contains( key3 ) ); System.out.println( "true == " + T.contains( new Int( 47 ) ) ); System.out.println( "false == " + T.contains( new Int( 148 ) ) ); System.out.println( "true == " + T.contains( new Int( 541 ) ) ); System.out.println( "36 maps to " + T.map( key2 ) ); System.out.println( "47 maps to " + T.map( new Int( 47 ) ) ); java.util.Enumeration e = T.elements( 36 ); System.out.println( "Elements with hash value of 36:" ); while ( e.hasMoreElements() ) System.out.println( " " + e.nextElement() ); e = T.elements( 12 ); System.out.println( "Elements with hash value of 12:" ); if ( ! e.hasMoreElements() ) System.out.println( " " ); else while ( e.hasMoreElements() ) System.out.println( " " + e.nextElement() ); T.remove( key2 ); T.remove( new Int( 137 ) ); System.out.println( T ); T.clear(); System.out.println( "Table size is " + T.getSize() + "." ); System.out.println( T ); } }