Free cookie consent management tool by TermsFeed Policy Generator

Changeset 3310


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

added RowNames for IStringConvertibleMatrix
and fixed cloning and ctors of concrete matrixes (ticket #968)

Location:
trunk/sources/HeuristicLab.Data/3.3
Files:
6 edited

Legend:

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

    r3308 r3310  
    2929  [StorableClass]
    3030  public class BoolMatrix : ValueTypeMatrix<bool>, IStringConvertibleMatrix {
    31     public BoolMatrix() : base() { }
     31        public BoolMatrix() : base() { }
    3232    public BoolMatrix(int rows, int columns) : base(rows, columns) { }
     33    public BoolMatrix(int rows, int columns, IEnumerable<string> columnNames) : base(rows, columns, columnNames) { }
     34    public BoolMatrix(int rows, int columns, IEnumerable<string> columnNames, IEnumerable<string> rowNames) : base(rows, columns, columnNames, rowNames) { }
    3335    public BoolMatrix(bool[,] elements) : base(elements) { }
     36    public BoolMatrix(bool[,] elements, IEnumerable<string> columnNames) : base(elements, columnNames) { }
     37    public BoolMatrix(bool[,] elements, IEnumerable<string> columnNames, IEnumerable<string> rowNames) : base(elements, columnNames, rowNames) { }
    3438
    3539    public override IDeepCloneable Clone(Cloner cloner) {
    3640      BoolMatrix clone = new BoolMatrix(matrix);
     41      clone.ColumnNames = new List<string>(ColumnNames);
     42      clone.RowNames = new List<string>(RowNames);
    3743      cloner.RegisterClonedObject(this, clone);
    3844      return clone;
     
    7884      set { this.ColumnNames = value; }
    7985    }
     86    IEnumerable<string> IStringConvertibleMatrix.RowNames {
     87      get { return this.RowNames; }
     88      set { this.RowNames = value; }
     89    }
    8090    bool IStringConvertibleMatrix.Validate(string value, out string errorMessage) {
    8191      return Validate(value, out errorMessage);
  • trunk/sources/HeuristicLab.Data/3.3/DoubleMatrix.cs

    r3308 r3310  
    3131    public DoubleMatrix() : base() { }
    3232    public DoubleMatrix(int rows, int columns) : base(rows, columns) { }
     33    public DoubleMatrix(int rows, int columns, IEnumerable<string> columnNames) : base(rows, columns, columnNames) { }
     34    public DoubleMatrix(int rows, int columns, IEnumerable<string> columnNames, IEnumerable<string> rowNames) : base(rows, columns, columnNames, rowNames) { }
    3335    public DoubleMatrix(double[,] elements) : base(elements) { }
     36    public DoubleMatrix(double[,] elements, IEnumerable<string> columnNames) : base(elements, columnNames) { }
     37    public DoubleMatrix(double[,] elements, IEnumerable<string> columnNames, IEnumerable<string> rowNames) : base(elements, columnNames, rowNames) { }
    3438
    3539    public override IDeepCloneable Clone(Cloner cloner) {
    3640      DoubleMatrix clone = new DoubleMatrix(matrix);
     41      clone.ColumnNames = new List<string>(ColumnNames);
     42      clone.RowNames = new List<string>(RowNames);
    3743      cloner.RegisterClonedObject(this, clone);
    3844      return clone;
     
    7884      set { this.ColumnNames = value; }
    7985    }
     86    IEnumerable<string> IStringConvertibleMatrix.RowNames {
     87      get { return this.RowNames; }
     88      set { this.RowNames = value; }
     89    }
    8090    bool IStringConvertibleMatrix.Validate(string value, out string errorMessage) {
    8191      return Validate(value, out errorMessage);
  • trunk/sources/HeuristicLab.Data/3.3/IStringConvertibleMatrix.cs

    r3308 r3310  
    3030
    3131    IEnumerable<string> ColumnNames { get; set; }
     32    IEnumerable<string> RowNames { get; set; }
    3233    //bool SortableView { get; }
    3334
  • trunk/sources/HeuristicLab.Data/3.3/IntMatrix.cs

    r3308 r3310  
    3131    public IntMatrix() : base() { }
    3232    public IntMatrix(int rows, int columns) : base(rows, columns) { }
     33    public IntMatrix(int rows, int columns, IEnumerable<string> columnNames) : base(rows, columns, columnNames) { }
     34    public IntMatrix(int rows, int columns, IEnumerable<string> columnNames,IEnumerable<string> rowNames) : base(rows, columns, columnNames,rowNames) { }
    3335    public IntMatrix(int[,] elements) : base(elements) { }
     36    public IntMatrix(int[,] elements, IEnumerable<string> columnNames) : base(elements,columnNames) { }
     37    public IntMatrix(int[,] elements, IEnumerable<string> columnNames, IEnumerable<string> rowNames) : base(elements,columnNames,rowNames) { }
    3438
    3539    public override IDeepCloneable Clone(Cloner cloner) {
    3640      IntMatrix clone = new IntMatrix(matrix);
     41      clone.ColumnNames = new List<string>(ColumnNames);
     42      clone.RowNames = new List<string>(RowNames);
    3743      cloner.RegisterClonedObject(this, clone);
    3844      return clone;
     
    7884      set { this.ColumnNames = value; }
    7985    }
     86    IEnumerable<string> IStringConvertibleMatrix.RowNames {
     87      get { return this.RowNames; }
     88      set { this.RowNames = value; }
     89    }
    8090    bool IStringConvertibleMatrix.Validate(string value, out string errorMessage) {
    8191      return Validate(value, out errorMessage);
  • trunk/sources/HeuristicLab.Data/3.3/StringMatrix.cs

    r3308 r3310  
    4242
    4343    [Storable]
    44     protected List<string> columnNames;
     44    private List<string> columnNames;
    4545    public IEnumerable<string> ColumnNames {
    4646      get { return this.columnNames; }
     
    4949          columnNames = new List<string>();
    5050        else if (value.Count() != Columns)
    51           throw new ArgumentException("A columnName must be for each column specified.");
     51          throw new ArgumentException("A column name must be specified for each column .");
    5252        else
    5353          columnNames = new List<string>(value);
     54      }
     55    }
     56    [Storable]
     57    private List<string> rowNames;
     58    public IEnumerable<string> RowNames {
     59      get { return this.rowNames; }
     60      set {
     61        if (value == null || value.Count() == 0)
     62          rowNames = new List<string>();
     63        else if (value.Count() != Rows)
     64          throw new ArgumentException("A row name must be specified for each row.");
     65        else
     66          rowNames = new List<string>(value);
    5467      }
    5568    }
     
    93106      matrix = new string[0, 0];
    94107      columnNames = new List<string>();
     108      rowNames = new List<string>();
    95109    }
    96110    public StringMatrix(int rows, int columns) {
     
    101115      }
    102116      columnNames = new List<string>();
     117      rowNames = new List<string>();
    103118    }
    104119    protected StringMatrix(int rows, int columns, IEnumerable<string> columnNames)
    105120      : this(rows, columns) {
    106121      ColumnNames = columnNames;
     122    }
     123    protected StringMatrix(int rows, int columns, IEnumerable<string> columnNames, IEnumerable<string> rowNames)
     124      : this(rows, columns,columnNames) {
     125      RowNames = rowNames;
    107126    }
    108127    public StringMatrix(string[,] elements) {
     
    114133      }
    115134      columnNames = new List<string>();
     135      rowNames = new List<string>();
    116136    }
    117137    protected StringMatrix(string[,] elements, IEnumerable<string> columnNames)
    118138      : this(elements) {
    119139      ColumnNames = columnNames;
     140    }
     141    protected StringMatrix(string[,] elements, IEnumerable<string> columnNames,IEnumerable<string> rowNames)
     142      : this(elements,columnNames) {
     143      RowNames = rowNames;
    120144    }
    121145
     
    124148      cloner.RegisterClonedObject(this, clone);
    125149      clone.matrix = (string[,])matrix.Clone();
     150      clone.columnNames = new List<string>(columnNames);
     151      clone.rowNames = new List<string>(rowNames);
    126152      return clone;
    127153    }
     
    193219      set { this.ColumnNames = value; }
    194220    }
     221    IEnumerable<string> IStringConvertibleMatrix.RowNames {
     222      get { return this.RowNames; }
     223      set { this.RowNames = value; }
     224    }
    195225    bool IStringConvertibleMatrix.Validate(string value, out string errorMessage) {
    196226      return Validate(value, out errorMessage);
  • trunk/sources/HeuristicLab.Data/3.3/ValueTypeMatrix.cs

    r3308 r3310  
    4242
    4343    [Storable]
    44     protected List<string> columnNames;
     44    private List<string> columnNames;
    4545    public IEnumerable<string> ColumnNames {
    4646      get { return this.columnNames; }
     
    4949          columnNames = new List<string>();
    5050        else if (value.Count() != Columns)
    51           throw new ArgumentException("A columnName must be for each column specified.");
     51          throw new ArgumentException("A column name must be specified for each column.");
    5252        else
    5353          columnNames = new List<string>(value);
     54      }
     55    }
     56    [Storable]
     57    private List<string> rowNames;
     58    public IEnumerable<string> RowNames {
     59      get { return this.rowNames; }
     60      set {
     61        if (value == null || value.Count() == 0)
     62          rowNames = new List<string>();
     63        else if (value.Count() != Rows)
     64          throw new ArgumentException("A row name must be specified for each row.");
     65        else
     66          rowNames = new List<string>(value);
    5467      }
    5568    }
     
    91104      matrix = new T[0, 0];
    92105      columnNames = new List<string>();
     106      rowNames = new List<string>();
    93107    }
    94108    protected ValueTypeMatrix(int rows, int columns) {
    95109      matrix = new T[rows, columns];
    96110      columnNames = new List<string>();
     111      rowNames = new List<string>();
    97112    }
    98113    protected ValueTypeMatrix(int rows, int columns, IEnumerable<string> columnNames)
     
    100115      ColumnNames = columnNames;
    101116    }
     117    protected ValueTypeMatrix(int rows, int columns, IEnumerable<string> columnNames,IEnumerable<string> rowNames)
     118      : this(rows, columns, columnNames) {
     119      RowNames = rowNames;
     120    }
    102121    protected ValueTypeMatrix(T[,] elements) {
    103122      if (elements == null) throw new ArgumentNullException();
    104123      matrix = (T[,])elements.Clone();
    105124      columnNames = new List<string>();
     125      rowNames = new List<string>();
    106126    }
    107127    protected ValueTypeMatrix(T[,] elements, IEnumerable<string> columnNames)
     
    109129      ColumnNames = columnNames;
    110130    }
     131    protected ValueTypeMatrix(T[,] elements, IEnumerable<string> columnNames, IEnumerable<string> rowNames)
     132      : this(elements,columnNames) {
     133      RowNames = rowNames;
     134    }
    111135
    112136    public override IDeepCloneable Clone(Cloner cloner) {
    113137      ValueTypeMatrix<T> clone = (ValueTypeMatrix<T>)base.Clone(cloner);
    114138      clone.matrix = (T[,])matrix.Clone();
     139      clone.columnNames = new List<string>(columnNames);
     140      clone.rowNames = new List<string>(rowNames);
    115141      return clone;
    116142    }
Note: See TracChangeset for help on using the changeset viewer.