/* ************************
* Name : Eugene Krapivin *
* ID : 306255084 *
* ***********************/
package driver;
import java.util.List;
import java.util.Vector;
import javax.swing.JFrame;
import exceptions.InvalidIntervalException;
import gui.MainFrame;
import nodes.IntervalNode;
import trees.BinarySearchTree;
import trees.IntervalTree;
/**
* This is a test driver for class BinarySearchTree.
* <p>
* methods checked: insert(int), remove(int), inorderIterative(),
* inorderRecursive().
*
* @see BinarySearchTree
* */
public class Program
{
static public void main(String[] args)
{
/*
* BinarySearchTree binTree = new BinarySearchTree(5);
*
* binTree.insert(3); binTree.insert(4); binTree.insert(1);
* binTree.insert(2); binTree.insert(8); binTree.insert(9);
* binTree.insert(7); binTree.insert(6); binTree.insert(10);
*
* System.out.print("Removing and inserting nubmers\nBefore check: ");
* binTree.inorderIterative(); System.out.println();
*
* // checking the insert, remove and inorderRecursive methods for (int
* i = 1; i < 11; i++) { binTree.remove(i); if (i == 1)
* System.out.println("Removed " + i + " : "); else
* System.out.print("Inserted " + (i - 1) + " back and removed " + i +
* " : "); binTree.inorderRecursive(); System.out.println();
* binTree.insert(i); } System.out
* .print("after check\nprinting tree in-order using iterative algorithm : "
* ); binTree.inorderIterative();
*
* System.out.print("\nChecking if number 99 is in the tree: " +
* binTree.search(99));
* System.out.println("\nChecking if number 9 is in the tree: " +
* binTree.search(9));
*
* System.out .println(
* "========================================================================"
* );
*
* IntervalTree intervalTree = new IntervalTree(3, 10);
*
* intervalTree.insert(5, 15); intervalTree.insert(4, 16);
* intervalTree.insert(10, 20); intervalTree.insert(1, 5);
* System.out.println("Trying to insert a bad interval:");
* intervalTree.insert(6, 5);
* System.out.println("Printing the tree after init:");
* System.out.println(intervalTree.toString());
*
* System.out.println("point 9 found in nodes"); List<IntervalNode>
* result = new Vector<IntervalNode>();
*
* intervalTree.search(9, result);
*
* for (IntervalNode n : result) { System.out.println(n.toString()); }
*
* System.out.println("interval [6,7] found in/intersects with nodes:");
* result = new Vector<IntervalNode>(); try { intervalTree.search(new
* IntervalNode(6, 7), result); } catch (InvalidIntervalException ex) {
* System.out.println(ex.getMessage()); }
*
* for (IntervalNode n : result) { System.out.println(n.toString()); }
*
* System.out
* .println("\nPrintout before removing interval with low-end 10:");
* System.out.println(intervalTree.toString()); intervalTree.remove(10);
* System.out
* .println("\nPrintout after removing interval with low-end 10:");
* System.out.println(intervalTree.toString());
*/
JFrame main = new MainFrame();
main.setVisible(true);
}
}