/*---------------------------------

  BST_int_Test.java

  (P) 1998 Laurentiu Cristofor

  test of BS_Tree_int class

-----------------------------------*/

class BST_int_Test
{
  static public void main(String[] args)
  {
    BS_Tree_int bsti = new BS_Tree_int();

    bsti.insert(16);
    bsti.insert(8);
    bsti.insert(24);
    bsti.insert(4);
    bsti.insert(12);
    bsti.insert(20);
    bsti.insert(28);
    bsti.insert(7);
    bsti.insert(9);
    bsti.insert(10);
    bsti.insert(8);
    bsti.insert(7);

    System.out.print("after initialization: ");

    BST_int_Iterator iter = bsti.iterator();

    while (!iter.atEnd())
      {
	System.out.print( iter.current() + " " );
	iter.next();
      }
    System.out.println();

    try
      {
	iter.current();
      }
    catch (NullPointerException e)
      {
	System.out.println("If we call current() on iter when iter is at the end of the tree, we get:");
	System.out.println(e);
      }

    System.out.print("contents >= 7: ");
    System.out.print("contents >= 7: ");

    iter = bsti.find(7);

    while (!iter.atEnd())
      {
	System.out.print( iter.current() + " " );
	iter.next();
      }
    System.out.println();

    System.out.print("after removal of one 7: ");

    bsti.remove(7);

    iter = bsti.iterator();

    while (!iter.atEnd())
      {
	System.out.print( iter.current() + " " );
	iter.next();
      }
    System.out.println();
  }
}
