コード例 #1
0
        /// <summary>
        /// Gets the input format.
        /// </summary>
        /// <returns></returns>
        public InputFormatModel GetInputFormat()
        {
            var lines            = Helpers.FileText.GetAllLinesOfFile(this.pathFile);
            var inputFormatModel = new InputFormatModel();

            SetNumberOfTestCase(inputFormatModel, lines);
            SetTestCases(inputFormatModel, lines);
            SetOperations(inputFormatModel, lines);
            return(inputFormatModel);
        }
コード例 #2
0
        /// <summary>
        /// Sets the test cases.
        /// </summary>
        /// <param name="inputFormatModel">The input format model.</param>
        /// <param name="lines">The lines.</param>
        private void SetTestCases(InputFormatModel inputFormatModel, string[] lines)
        {
            for (int i = 1; i < lines.Length; i++)
            {
                var testCase           = lines[i].Split(' ');
                var dimensionOfMatrix  = Convert.ToInt32(testCase[0]);
                var numberOfOperations = Convert.ToInt32(testCase[1]);

                inputFormatModel.TestCases.Add(new TestCasesModel()
                {
                    DimensionOfMatrix  = dimensionOfMatrix,
                    NumberOfOperations = numberOfOperations
                });

                i += numberOfOperations;
            }
        }
コード例 #3
0
        /// <summary>
        /// Gets the sum total of each query operation.
        /// </summary>
        /// <param name="inputFormatModel">The input format model.</param>
        /// <returns></returns>
        public List <int> GetSumTotalOfEachQueryOperation(InputFormatModel inputFormatModel)
        {
            var result = new List <int>();

            foreach (var testCase in inputFormatModel.TestCases)
            {
                testCase.DimensionOfMatrix += CubeSummationCube3DConstAndEnum.IntializeToFirstBlock;

                this.cube3D = new int[testCase.DimensionOfMatrix, testCase.DimensionOfMatrix, testCase.DimensionOfMatrix];

                foreach (var operation in testCase.Operations)
                {
                    operation.Excecute(this.cube3D);
                    if (operation.AnyValueOfReturn)
                    {
                        result.Add(operation.Result);
                    }
                }
            }
            return(result);
        }
コード例 #4
0
        /// <summary>
        /// Sets the operations.
        /// </summary>
        /// <param name="inputFormatModel">The input format model.</param>
        /// <param name="lines">The lines.</param>
        private void SetOperations(InputFormatModel inputFormatModel, string[] lines)
        {
            var positionTestCase = 0;

            for (int i = 1; i < lines.Length; i++)
            {
                var numberOfOperations         = Convert.ToInt32(lines[i].Split(' ')[1]);
                var currentPositionOfOperation = i + 1;
                var indexPositionOfOperation   = 0;
                inputFormatModel.TestCases[positionTestCase].Operations = new IOperation[numberOfOperations];

                i += numberOfOperations;

                while (numberOfOperations > 0)
                {
                    if (lines[currentPositionOfOperation].StartsWith(InputFormatConstAndEnum.OperatonUpdateStartWith))
                    {
                        var updateBusiness = new UpdateBusiness();
                        updateBusiness.UpdateModels = GetUpdateModelsToOperationModel(lines, currentPositionOfOperation);
                        inputFormatModel.TestCases[positionTestCase].Operations[indexPositionOfOperation] = updateBusiness;
                    }
                    else
                    if (lines[currentPositionOfOperation].StartsWith(InputFormatConstAndEnum.OperationQueryStartWith))
                    {
                        var queryBusiness = new QueryBusiness();
                        queryBusiness.QueryModels = GetQueryModelsToOperationModel(lines, currentPositionOfOperation);
                        inputFormatModel.TestCases[positionTestCase].Operations[indexPositionOfOperation] = queryBusiness;
                    }

                    currentPositionOfOperation += 1;
                    numberOfOperations         -= 1;
                    indexPositionOfOperation   += 1;
                }

                positionTestCase += 1;
            }
        }
コード例 #5
0
 /// <summary>
 /// Sets the number of test case.
 /// </summary>
 /// <param name="inputFormatModel">The input format model.</param>
 /// <param name="lines">The lines.</param>
 private void SetNumberOfTestCase(InputFormatModel inputFormatModel, string[] lines)
 {
     inputFormatModel.NumberOfTestCase = Convert.ToInt32(lines[0]);
 }