Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.DataImporter/HeuristicLab.DataImporter.Command/Aggregation/AggregateWithMinCommand.cs @ 6133

Last change on this file since 6133 was 6133, checked in by gkronber, 13 years ago

#1471: imported generic parts of DataImporter from private code base

File size: 1.4 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using HeuristicLab.DataImporter.Data;
6using HeuristicLab.DataImporter.Data.CommandBase;
7using HeuristicLab.DataImporter.Data.Model;
8using HeuristicLab.DataImporter.Command.View;
9using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
10
11namespace HeuristicLab.DataImporter.Command {
12  [StorableClass]
13  [ViewableCommandInfoAttribute("Minimum", 1, ColumnGroupState.DoubleColumnSelected | ColumnGroupState.AnySelectedColumnNotSorted,
14   "Aggregation", Position = 3, OptionsView = typeof(AggregationCommandView))]
15  public class AggregateWithMinCommand : AggregateCommandBase {
16
17    private AggregateWithMinCommand()
18      : base(null, string.Empty, null) {
19    }
20
21    public AggregateWithMinCommand(DataSet dataSet, string columnGroupName, int[] affectedColumns)
22      : base(dataSet, columnGroupName, affectedColumns) {
23    }
24
25    public override string Description {
26      get { return "Aggregate with min function"; }
27    }
28
29    protected override IComparable AggregationFunction(ColumnBase col, int startIndex, int endIndex) {
30      IComparable minValue = null;
31      IComparable val;
32      for (int i = startIndex; i < endIndex; i++) {
33        val = col.GetValue(i);
34        if (val != null) {
35          if (minValue == null || val.CompareTo(minValue) < 0)
36            minValue = val;
37        }
38      }
39      return minValue;
40    }
41  }
42}
Note: See TracBrowser for help on using the repository browser.