Changeset 12032 for branches/HeuristicLab.DatasetRefactor
- Timestamp:
- 02/18/15 11:02:11 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Problems.DataAnalysis/3.4/ModifiableDataset.cs
r11589 r12032 2 2 3 3 /* HeuristicLab 4 * Copyright (C) 2002-201 4Heuristic and Evolutionary Algorithms Laboratory (HEAL)4 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 5 5 * 6 6 * This file is part of HeuristicLab. … … 74 74 } 75 75 76 // adds a new variable to the dataset 77 public void AddVariable<T>(string variableName, IEnumerable<T> values) { 78 if (variableValues.ContainsKey(variableName)) 79 throw new ArgumentException("Variable " + variableName + " is already present in the dataset."); 80 int count = values.Count(); 81 if (count != rows) 82 throw new ArgumentException("The number of values must exactly match the number of rows in the dataset."); 83 variableValues[variableName] = new List<T>(values); 84 variableNames.Add(variableName); 85 } 86 87 public void RemoveVariable(string variableName) { 88 if (!variableValues.ContainsKey(variableName)) 89 throw new ArgumentException("The variable " + variableName + " does not exist in the dataset."); 90 variableValues.Remove(variableName); 91 variableNames.Remove(variableName); 92 } 93 76 94 // slow, avoid to use this 77 95 public void RemoveRow(int row) { … … 79 97 list.RemoveAt(row); 80 98 rows--; 99 } 100 101 public void ChangeVariableValue(object value, string variableName, int row) { 102 IList list; 103 variableValues.TryGetValue(variableName, out list); 104 if (list == null) 105 throw new ArgumentException("The variable " + variableName + " does not exist in the dataset."); 106 if (row < 0 || list.Count < row) 107 throw new ArgumentOutOfRangeException("Invalid row value"); 108 list[row] = value; 81 109 } 82 110
Note: See TracChangeset
for help on using the changeset viewer.