Free cookie consent management tool by TermsFeed Policy Generator

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

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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);
Note: See TracChangeset for help on using the changeset viewer.