Free cookie consent management tool by TermsFeed Policy Generator

Changeset 8564


Ignore:
Timestamp:
09/04/12 11:24:29 (12 years ago)
Author:
gkronber
Message:

#1890

  • added an extension to calculate the range of IEnumerable<double>
  • increased the buffer size for the heuristic determination of separator characters in the table file parser (to make it work with files that have more than 1024 bytes in the second line).
Location:
trunk/sources
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Common/3.3/EnumerableStatisticExtensions.cs

    r8531 r8564  
    4545        return (valuesArr[(n / 2) - 1] + valuesArr[n / 2]) / 2.0;
    4646      }
     47    }
     48
     49    /// <summary>
     50    /// Calculates the range (max - min) of the enumeration.
     51    /// </summary>
     52    /// <param name="values"></param>
     53    /// <returns></returns>
     54    public static double Range(this IEnumerable<double> values) {
     55      double min = double.PositiveInfinity;
     56      double max = double.NegativeInfinity;
     57      int i = 0;
     58      foreach (var e in values) {
     59        if (min > e) min = e;
     60        if (max < e) max = e;
     61        i++;
     62      }
     63      if (i <= 2) throw new ArgumentException("The enumerable must contain at least two elements", "values");
     64      return max - min;
    4765    }
    4866
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/TableFileParser.cs

    r7851 r8564  
    3232namespace HeuristicLab.Problems.Instances.DataAnalysis {
    3333  public class TableFileParser {
    34     private const int BUFFER_SIZE = 1024;
     34    private const int BUFFER_SIZE = 65536;
    3535    private static readonly char[] POSSIBLE_SEPARATORS = new char[] { ',', ';', '\t' };
    3636    private Tokenizer tokenizer;
Note: See TracChangeset for help on using the changeset viewer.