Пример #1
0
        /// <summary>
        /// Three arguments expected - name of the input file, name of the output file and type of the tree to be built - STANDARD, NAIVE or OPTIMAL.
        /// </summary>
        /// <param name="args">Arguments of the program.</param>
        static void Main(string[] args)
        {
            if (args.Length != 3)
            {
                Console.WriteLine("Three args expected, name of input and output file, and tree type - STANDARD or NAIVE.");
                return;
            }
            SplayTreeType type = SplayTreeType.NAIVE;

            if (args[2] == "STANDARD")
            {
                type = SplayTreeType.STANDARD;
            }
            else if (args[2] == "NAIVE")
            {
                type = SplayTreeType.NAIVE;
            }
            else if (args[2] == "OPTIMAL")
            {
                type = SplayTreeType.OPTIMAL;
            }
            else
            {
                Console.WriteLine("STANDARD, NAIVE, or OPTIMAL expected as the third argument");
            }
            TreeGenerator generator = new TreeGenerator(args[0], args[1], type);

            generator.CreateTree();
            generator.FinishCurrentTree();
            generator.writer.Close();
        }
Пример #2
0
 /// <summary>
 /// Initialize tree generator.
 /// </summary>
 /// <param name="input">Name of input file</param>
 /// <param name="output">Name of output file</param>
 /// <param name="typ">Type of the tree to be built/param>
 public TreeGenerator(string input, string output, SplayTreeType typ)
 {
     filename = input;
     writer   = new StreamWriter(output);
     type     = typ;
 }
Пример #3
0
 /// <summary>
 /// Initializes new tree.
 /// </summary>
 /// <param name="type">Type of the tree.</param>
 public SplayTree(SplayTreeType type)
 {
     this.type = type;
 }