コード例 #1
0
 public IncrementalIQMManager(string path,
                              CalculationType calcType          = CalculationType.Modified,
                              InsertionType insertionType       = InsertionType.InsertInPlace,
                              HandleResultsMethod handleResults = null)
 {
     FilePath      = path;
     CalcType      = calcType;
     InsertType    = insertionType;
     HandleResults = handleResults ?? HandleResultsDefault;
 }
コード例 #2
0
        public double Execute(string filePath, CalculationType calcType, InsertionType insertType,
                              HandleResultsMethod handleResults = null)
        {
            if (string.IsNullOrEmpty(filePath))
            {
                throw new ArgumentNullException(paramName: "FilePath", message: "File Path not defined");
            }

            var InsertData    = SetInsertionMethod(insertType);
            var CalculateMean = SetCalculateMethod(calcType);

            HandleResults = handleResults ?? HandleResults; // if a new HandleResultsMethod is passed use it

            DateTime beforeTime = DateTime.Now;

            try
            {
                List <int> data = new List <int>();
                using (StreamReader sr = new StreamReader(filePath))
                {
                    var line = "";
                    // reads through each line in the file & calculates the intermediate IQM
                    while ((line = sr.ReadLine()) != null)
                    {
                        InsertData(data, Convert.ToInt32(line));
                        if (data.Count >= 4)
                        {
                            var mean = CalculateMean(data);
                            HandleResults(data.Count, mean);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("The file could not be read:");
                Console.WriteLine(e.Message);
            }

            DateTime afterTime = DateTime.Now;
            TimeSpan diff      = afterTime - beforeTime;

            return(diff.TotalMilliseconds);
        }
コード例 #3
0
 public IncrementalIQMManager(string path, HandleResultsMethod handleResults)
     : this(path, CalculationType.Modified, InsertionType.InsertInPlace, handleResults)
 {
 }
コード例 #4
0
 public double Execute(HandleResultsMethod handleResults)
 {
     return(Execute(FilePath, CalcType, InsertType, handleResults));
 }