Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/12/10 14:14:39 (14 years ago)
Author:
mkommend
Message:

added ColumnNames property in IStringConvertibleMatrix and in classes implementing this interface (ticket #968)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Data/3.3/ValueTypeMatrix.cs

    r3306 r3308  
    2222using System;
    2323using System.Collections;
     24using System.Collections.Generic;
    2425using System.Drawing;
     26using System.Linq;
    2527using System.Text;
    2628using HeuristicLab.Common;
     
    3840    [Storable]
    3941    protected T[,] matrix;
     42
     43    [Storable]
     44    protected List<string> columnNames;
     45    public IEnumerable<string> ColumnNames {
     46      get { return this.columnNames; }
     47      set {
     48        if (value == null || value.Count() == 0)
     49          columnNames = new List<string>();
     50        else if (value.Count() != Columns)
     51          throw new ArgumentException("A columnName must be for each column specified.");
     52        else
     53          columnNames = new List<string>(value);
     54      }
     55    }
    4056
    4157    public virtual int Rows {
     
    7490    protected ValueTypeMatrix() {
    7591      matrix = new T[0, 0];
     92      columnNames = new List<string>();
    7693    }
    7794    protected ValueTypeMatrix(int rows, int columns) {
    7895      matrix = new T[rows, columns];
     96      columnNames = new List<string>();
     97    }
     98    protected ValueTypeMatrix(int rows, int columns, IEnumerable<string> columnNames)
     99      : this(rows, columns) {
     100      ColumnNames = columnNames;
    79101    }
    80102    protected ValueTypeMatrix(T[,] elements) {
    81103      if (elements == null) throw new ArgumentNullException();
    82104      matrix = (T[,])elements.Clone();
     105      columnNames = new List<string>();
     106    }
     107    protected ValueTypeMatrix(T[,] elements, IEnumerable<string> columnNames)
     108      : this(elements) {
     109      ColumnNames = columnNames;
    83110    }
    84111
Note: See TracChangeset for help on using the changeset viewer.