/** This program is intended to be used with the book "Java 6 -- What Do You Want To Do?"
 * by Steven P. Warr and is distributed free of charge and without and expectations of remuneration.
 * Chapter DAT   NOTE most programs begin with the title of the chapter in which
 * they are intended to be used.   Copyright 2010 Steven P. Warr All rights reserved
	TreeSet Example.
 */

import java.io.*;   		//needed so you can use the File class
import java.util.*;  		//needed for Lists
public class Dat05
{
	public static void main(String[ ] args) throws IOException
		{
            TreeSet <Character> ts = new TreeSet <Character>();                                  
			ts.add('X');              // adds letter to the top of the Tree                     
			ts.add('B');                                              
			ts.add('C');                                              
			System.out.println("The tree in order " + ts);    	//[B, C, X]                                          
			ts.remove('B');    									// removes B
			System.out.println("The tree in order " + ts);    	//[C, X]                                          
			ts.add('D');                                              
			ts.add('E');                                              
			System.out.println("The tree in order " + ts);    	//[C, D, E, X]                                          
			ts.remove('E');    									// removes E
			System.out.println("The tree in order " + ts);    	//[C, D, X]                                          
			ts.add('F');                                              
			System.out.println("The tree in order " + ts);    	//[C, D, F, X]                                          
			System.out.println("is there an X? " + ts.contains('X'));             
			System.out.println("is there an M? " + ts.contains('M'));             
			ts.remove ('X');
			System.out.println("The tree in order " + ts);    	//[C, D, F]                                          
			for(char x:ts)
			    System.out.println("The tree one at a time " + x);   // for - each automates get 
            
        }

}
