Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/09/14 13:32:50 (10 years ago)
Author:
rstoll
Message:
  • changed variableValues from Dictionary<int, IList> to IList<Ilist> because this way DeleteColumn works correctly without any modification of the keys (otherwise the keys would need to be rewriten)
Location:
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/PreprocessingData.cs

    r10695 r10740  
    3434  public class PreprocessingData : NamedItem, IPreprocessingData {
    3535
    36     protected IDictionary<int, IList> variableValues;
     36    protected IList<IList> variableValues;
    3737
    3838    protected IList<string> variableNames;
     
    5757
    5858      int columnIndex = 0;
    59       variableValues = new Dictionary<int, IList>();
     59      variableValues = new List<IList>();
    6060      foreach (var variableName in problemData.Dataset.VariableNames) {
    6161        if (problemData.Dataset.IsType<double>(variableName)) {
    62           variableValues[columnIndex] = problemData.Dataset.GetDoubleValues(variableName).ToList();
     62          variableValues.Insert(columnIndex, problemData.Dataset.GetDoubleValues(variableName).ToList());
    6363        } else if (problemData.Dataset.IsType<string>(variableName)) {
    64           variableValues[columnIndex] = CreateColumn<string>(problemData.Dataset, columnIndex, x => x);
     64          variableValues.Insert(columnIndex, CreateColumn<string>(problemData.Dataset, columnIndex, x => x));
    6565        } else if (problemData.Dataset.IsType<DateTime>(variableName)) {
    66           variableValues[columnIndex] = CreateColumn<DateTime>(problemData.Dataset, columnIndex, x => DateTime.Parse(x));
     66          variableValues.Insert(columnIndex, CreateColumn<DateTime>(problemData.Dataset, columnIndex, x => DateTime.Parse(x)));
    6767        } else {
    6868          throw new ArgumentException("The datatype of column " + variableName + " must be of type List<double>, List<string> or List<DateTime>");
     
    8282    }
    8383
    84     protected IDictionary<int, IList> CopyVariableValues(IDictionary<int, IList> original) {
    85       var copy = new Dictionary<int, IList>(variableValues);
    86       for (int i = 0; i < original.Count; i++) {
     84    protected IList<IList> CopyVariableValues(IList<IList> original) {
     85      var copy = new List<IList>(variableValues);
     86      for (int i = 0; i < original.Count; ++i) {
    8787        variableValues[i] = (IList)Activator.CreateInstance(original[i].GetType(), original[i]);
    8888      }
     
    133133
    134134    public virtual void InsertRow(int rowIndex) {
    135       foreach (IList column in variableValues.Values) {
     135      foreach (IList column in variableValues) {
    136136        Type type = column.GetType().GetGenericArguments()[0];
    137137        column.Insert(rowIndex, type.IsValueType ? Activator.CreateInstance(type) : null);
     
    140140
    141141    public virtual void DeleteRow(int rowIndex) {
    142       foreach (IList column in variableValues.Values) {
     142      foreach (IList column in variableValues) {
    143143        column.RemoveAt(rowIndex);
    144144      }
     
    146146
    147147    public virtual void InsertColumn<T>(string variableName, int columnIndex) {
    148       variableValues.Add(columnIndex, new List<T>(Rows));
     148      variableValues.Insert(columnIndex, new List<T>(Rows));
    149149      variableNames.Insert(columnIndex, variableName);
    150150    }
    151151
    152152    public virtual void DeleteColumn(int columnIndex) {
    153       variableValues.Remove(columnIndex);
     153      variableValues.RemoveAt(columnIndex);
    154154      variableNames.RemoveAt(columnIndex);
    155155    }
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/TransactionalPreprocessingData.cs

    r10665 r10740  
    3030
    3131  internal class PDSnapshot {
    32     public IDictionary<int, IList> VariableValues { get; set; }
     32    public IList<IList> VariableValues { get; set; }
    3333
    3434    public IList<string> VariableNames { get; set; }
Note: See TracChangeset for help on using the changeset viewer.