- Timestamp:
- 05/14/14 11:36:10 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/FilterLogic.cs
r10802 r10843 20 20 #endregion 21 21 22 using System.Collections.Generic; 23 using System.Linq; 22 24 using HeuristicLab.DataPreprocessing.Filter; 23 using System.Collections.Generic;24 using System;25 using System.Linq;26 25 using HeuristicLab.DataPreprocessing.Interfaces; 27 26 namespace HeuristicLab.DataPreprocessing { … … 30 29 private IFilteredPreprocessingData preprocessingData; 31 30 32 public FilterLogic(IFilteredPreprocessingData preprocessingData) 33 { 31 public FilterLogic(IFilteredPreprocessingData preprocessingData) { 34 32 this.preprocessingData = preprocessingData; 35 33 } 36 34 37 public bool[] Preview(IList<IFilter> filters, bool isAndCombination)38 {39 IList<IFilter> activeFilters = filters.Where(f => f.Active && f.ConstraintData != null).ToList<IFilter>();40 35 41 if (activeFilters.Count == 0) { 36 37 public bool[] Preview(IList<IFilter> filters, bool isAndCombination) { 38 IList<IFilter> activeFilters = filters.Where(f => f.Active && f.ConstraintData != null).ToList<IFilter>(); 39 40 if (activeFilters.Count == 0) { 42 41 return new bool[preprocessingData.Rows]; 43 42 } 44 43 45 bool[] result = TrueBoolArray(preprocessingData.Rows);44 bool[] result = CreateBoolArray(preprocessingData.Rows, isAndCombination); 46 45 47 foreach (IFilter filter in activeFilters) 48 { 49 bool[] filterResult = filter.Check(); 50 for (int row = 0; row < result.Length; ++row) 51 { 52 result[row] = Result(result[row], filterResult[row], isAndCombination); 53 } 54 } 46 foreach (IFilter filter in activeFilters) { 47 bool[] filterResult = filter.Check(); 48 for (int row = 0; row < result.Length; ++row) { 49 result[row] = Result(result[row], filterResult[row], isAndCombination); 50 } 51 } 55 52 56 57 58 53 preprocessingData.SetFilter(result); 54 55 return result; 59 56 } 60 57 61 public bool[] TrueBoolArray(int rows) {62 return Enumerable.Repeat<bool>( true, rows).ToArray();58 public bool[] CreateBoolArray(int rows, bool value) { 59 return Enumerable.Repeat<bool>(value, rows).ToArray(); 63 60 } 64 61 65 public bool Result(bool current, bool addition, bool isAndCombination) { 62 public bool Result(bool current, bool addition, bool isAndCombination) { 66 63 return isAndCombination ? current && addition : current || addition; 67 64 } 68 65 69 public void Apply(IList<IFilter> filters, bool isAndCombination) 70 { 71 preprocessingData.SetFilter(Preview(filters, isAndCombination)); 72 preprocessingData.PersistFilter(); 66 public void Apply(IList<IFilter> filters, bool isAndCombination) { 67 preprocessingData.SetFilter(Preview(filters, isAndCombination)); 68 preprocessingData.PersistFilter(); 73 69 } 74 70 … … 77 73 } 78 74 79 public IPreprocessingData PreprocessingData 80 { 75 public IPreprocessingData PreprocessingData { 81 76 get { return preprocessingData; } 82 77 }
Note: See TracChangeset
for help on using the changeset viewer.