Input.read_scans_file C# (CSharp) Method

read_scans_file() public method

public read_scans_file ( ) : void
return void
    public void read_scans_file()
    {
        scans = new List<InputScan>();
        read_scan_black_list();
        StreamReader f = new StreamReader(data_file_path("scans.txt"));

        string line;

        while ((line = f.ReadLine()) != null)
        {
            InputScan scan = InputScan.from_line(line);

            if (! blacklist.Exists(i => i == scan.id))
            {
                scans.Add(scan);
            }
        }

        calc_scan_array();
    }

Usage Example

Example #1
0
    static void Main(string[] args)
    {
        string cmd = ((args.Length >= 1) ? args[0] : "");

        if (cmd == "test_blacklist")
        {
            Input i = new Input(start_board, num_boards);
            i.read_scan_black_list();

            foreach (int blacked in i.blacklist)
            {
                Console.WriteLine(blacked);
            }
        }
        else if (cmd == "test_lookup_scan_cmd_line_by_id")
        {
            Input input = new Input(start_board, num_boards);
            input.read_scans_file();

            int id = Convert.ToInt32(args[1]);

            InputScan scan = input.scans.Find(e => e.id == id);
            Console.WriteLine(scan.cmd_line);
        }
        else if (cmd == "test_lookup_iters")
        {
            Input input = new Input(start_board, num_boards);
            input.read_data();

            int scan_id   = Convert.ToInt32(args[1]);
            int board_idx = Convert.ToInt32(args[2]);

            int scan_idx = 0;
            foreach (InputScan scan in input.scans)
            {
                if (scan.id == scan_id)
                {
                    break;
                }
                scan_idx++;
            }

            Console.WriteLine(input.scans_data[scan_idx, (board_idx - input.start_board)]);
        }
        else if (cmd == "test_process_sample_run")
        {
            Input input = new Input(start_board, num_boards);
            input.read_data();

            Process p = new Process(input);
            p.SampleRun();
        }
        else if (cmd == "test_process_sample_run_with_constant_quotas")
        {
            Input input = new Input(start_board, num_boards);
            input.read_data();

            int quota_value = Convert.ToInt32(args[1]);

            Process p = new Process(input);
            p.SampleRunWithConstantQuotas(quota_value);
        }
        else if (cmd == "find_optimal_quotas")
        {
            Input input = new Input(start_board, num_boards);
            input.read_data();

            int iters_num = Convert.ToInt32(args[1]);

            Process p = new Process(input);
            p.FindOptimalQuotas(iters_num);
        }
        // List<double> myList = new List<double>();
        else
        {
            Console.WriteLine("Hello World!");
        }
    }
All Usage Examples Of Input::read_scans_file