Free cookie consent management tool by TermsFeed Policy Generator

Changeset 3054


Ignore:
Timestamp:
03/16/10 04:24:01 (14 years ago)
Author:
swagner
Message:

Refactored classes of HeuristicLab.Data and implemented encoding specific data classes (#909)

Location:
trunk/sources
Files:
3 added
7 deleted
25 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.SGA/3.3/Tests/HeuristicLab.Algorithms.SGA-3.3.Tests.csproj

    r3053 r3054  
    7878  </ItemGroup>
    7979  <ItemGroup>
     80    <ProjectReference Include="..\..\..\HeuristicLab.Algorithms.TS\3.3\HeuristicLab.Algorithms.TS-3.3.csproj">
     81      <Project>{D58A232D-04BA-4186-B73E-0EC86FD31ABE}</Project>
     82      <Name>HeuristicLab.Algorithms.TS-3.3</Name>
     83    </ProjectReference>
    8084    <ProjectReference Include="..\..\..\HeuristicLab.Analysis\3.3\HeuristicLab.Analysis-3.3.csproj">
    8185      <Project>{887425B4-4348-49ED-A457-B7D2C26DDBF9}</Project>
  • trunk/sources/HeuristicLab.Data/3.3/BoolArray.cs

    r3048 r3054  
    2828  [Creatable("Test")]
    2929  [StorableClass]
    30   public sealed class BoolArray : ValueTypeArray<bool>, IStringConvertibleArray {
     30  public class BoolArray : ValueTypeArray<bool>, IStringConvertibleArray {
    3131    public BoolArray() : base() { }
    3232    public BoolArray(int length) : base(length) { }
    3333    public BoolArray(bool[] elements) : base(elements) { }
    34     private BoolArray(BoolArray elements) : base(elements) { }
    3534
    3635    public override IDeepCloneable Clone(Cloner cloner) {
    37       BoolArray clone = new BoolArray(this);
     36      BoolArray clone = new BoolArray(array);
    3837      cloner.RegisterClonedObject(this, clone);
    3938      return clone;
    4039    }
    4140
    42     #region IStringConvertibleArray Members
    43     int IStringConvertibleArray.Length {
    44       get { return Length; }
    45       set { Length = value; }
    46     }
    47 
    48     bool IStringConvertibleArray.Validate(string value, out string errorMessage) {
     41    protected virtual bool Validate(string value, out string errorMessage) {
    4942      bool val;
    5043      bool valid = bool.TryParse(value, out val);
     
    5952      return valid;
    6053    }
    61     string IStringConvertibleArray.GetValue(int index) {
     54    protected virtual string GetValue(int index) {
    6255      return this[index].ToString();
    6356    }
    64     bool IStringConvertibleArray.SetValue(string value, int index) {
     57    protected virtual bool SetValue(string value, int index) {
    6558      bool val;
    6659      if (bool.TryParse(value, out val)) {
     
    7164      }
    7265    }
     66
     67    #region IStringConvertibleArray Members
     68    int IStringConvertibleArray.Length {
     69      get { return Length; }
     70      set { Length = value; }
     71    }
     72    bool IStringConvertibleArray.Validate(string value, out string errorMessage) {
     73      return Validate(value, out errorMessage);
     74    }
     75    string IStringConvertibleArray.GetValue(int index) {
     76      return GetValue(index);
     77    }
     78    bool IStringConvertibleArray.SetValue(string value, int index) {
     79      return SetValue(value, index);
     80    }
    7381    #endregion
    7482  }
  • trunk/sources/HeuristicLab.Data/3.3/BoolMatrix.cs

    r3048 r3054  
    2828  [Creatable("Test")]
    2929  [StorableClass]
    30   public sealed class BoolMatrix : ValueTypeMatrix<bool>, IStringConvertibleMatrix {
     30  public class BoolMatrix : ValueTypeMatrix<bool>, IStringConvertibleMatrix {
    3131    public BoolMatrix() : base() { }
    3232    public BoolMatrix(int rows, int columns) : base(rows, columns) { }
    3333    public BoolMatrix(bool[,] elements) : base(elements) { }
    34     private BoolMatrix(BoolMatrix elements) : base(elements) { }
    3534
    3635    public override IDeepCloneable Clone(Cloner cloner) {
    37       BoolMatrix clone = new BoolMatrix(this);
     36      BoolMatrix clone = new BoolMatrix(matrix);
    3837      cloner.RegisterClonedObject(this, clone);
    3938      return clone;
    4039    }
    4140
    42     #region IStringConvertibleMatrix Members
    43     int IStringConvertibleMatrix.Rows {
    44       get { return Rows; }
    45       set { Rows = value; }
    46     }
    47     int IStringConvertibleMatrix.Columns {
    48       get { return Columns; }
    49       set { Columns = value; }
    50     }
    51 
    52     bool IStringConvertibleMatrix.Validate(string value, out string errorMessage) {
     41    protected virtual bool Validate(string value, out string errorMessage) {
    5342      bool val;
    5443      bool valid = bool.TryParse(value, out val);
     
    6352      return valid;
    6453    }
    65     string IStringConvertibleMatrix.GetValue(int rowIndex, int columIndex) {
     54    protected virtual string GetValue(int rowIndex, int columIndex) {
    6655      return this[rowIndex, columIndex].ToString();
    6756    }
    68     bool IStringConvertibleMatrix.SetValue(string value, int rowIndex, int columnIndex) {
     57    protected virtual bool SetValue(string value, int rowIndex, int columnIndex) {
    6958      bool val;
    7059      if (bool.TryParse(value, out val)) {
     
    7564      }
    7665    }
     66
     67    #region IStringConvertibleMatrix Members
     68    int IStringConvertibleMatrix.Rows {
     69      get { return Rows; }
     70      set { Rows = value; }
     71    }
     72    int IStringConvertibleMatrix.Columns {
     73      get { return Columns; }
     74      set { Columns = value; }
     75    }
     76    bool IStringConvertibleMatrix.Validate(string value, out string errorMessage) {
     77      return Validate(value, out errorMessage);
     78    }
     79    string IStringConvertibleMatrix.GetValue(int rowIndex, int columIndex) {
     80      return GetValue(rowIndex, columIndex);
     81    }
     82    bool IStringConvertibleMatrix.SetValue(string value, int rowIndex, int columnIndex) {
     83      return SetValue(value, rowIndex, columnIndex);
     84    }
    7785    #endregion
    7886  }
  • trunk/sources/HeuristicLab.Data/3.3/BoolValue.cs

    r3048 r3054  
    2929  [Creatable("Test")]
    3030  [StorableClass]
    31   public sealed class BoolValue : ValueTypeValue<bool>, IComparable, IStringConvertibleValue {
     31  public class BoolValue : ValueTypeValue<bool>, IComparable, IStringConvertibleValue {
    3232    public BoolValue() : base() { }
    3333    public BoolValue(bool value) : base(value) { }
    3434
    3535    public override IDeepCloneable Clone(Cloner cloner) {
    36       BoolValue clone = new BoolValue(Value);
     36      BoolValue clone = new BoolValue(value);
    3737      cloner.RegisterClonedObject(this, clone);
    3838      return clone;
    3939    }
    4040
    41     public int CompareTo(object obj) {
     41    public virtual int CompareTo(object obj) {
    4242      BoolValue other = obj as BoolValue;
    4343      if (other != null)
     
    4747    }
    4848
    49     #region IStringConvertibleValue Members
    50     bool IStringConvertibleValue.Validate(string value, out string errorMessage) {
     49    protected virtual bool Validate(string value, out string errorMessage) {
    5150      bool val;
    5251      bool valid = bool.TryParse(value, out val);
     
    6160      return valid;
    6261    }
    63     string IStringConvertibleValue.GetValue() {
     62    protected virtual string GetValue() {
    6463      return Value.ToString();
    6564    }
    66     bool IStringConvertibleValue.SetValue(string value) {
     65    protected virtual bool SetValue(string value) {
    6766      bool val;
    6867      if (bool.TryParse(value, out val)) {
     
    7372      }
    7473    }
     74
     75    #region IStringConvertibleValue Members
     76    bool IStringConvertibleValue.Validate(string value, out string errorMessage) {
     77      return Validate(value, out errorMessage);
     78    }
     79    string IStringConvertibleValue.GetValue() {
     80      return GetValue();
     81    }
     82    bool IStringConvertibleValue.SetValue(string value) {
     83      return SetValue(value);
     84    }
    7585    #endregion
    7686  }
  • trunk/sources/HeuristicLab.Data/3.3/Comparison.cs

    r3048 r3054  
    2828  [Creatable("Test")]
    2929  [StorableClass]
    30   public sealed class Comparison : ValueTypeValue<ComparisonType>, IComparable {
     30  public class Comparison : ValueTypeValue<ComparisonType>, IComparable {
    3131    public Comparison() : base() { }
    3232    public Comparison(ComparisonType value) : base(value) { }
    3333
    3434    public override IDeepCloneable Clone(Cloner cloner) {
    35       Comparison clone = new Comparison(Value);
     35      Comparison clone = new Comparison(value);
    3636      cloner.RegisterClonedObject(this, clone);
    3737      return clone;
    3838    }
    3939
    40     public int CompareTo(object obj) {
     40    public virtual int CompareTo(object obj) {
    4141      Comparison other = obj as Comparison;
    4242      if (other != null)
  • trunk/sources/HeuristicLab.Data/3.3/DateTimeValue.cs

    r3048 r3054  
    2828  [Creatable("Test")]
    2929  [StorableClass]
    30   public sealed class DateTimeValue : ValueTypeValue<DateTime>, IComparable, IStringConvertibleValue {
     30  public class DateTimeValue : ValueTypeValue<DateTime>, IComparable, IStringConvertibleValue {
    3131    public DateTimeValue() : base() { }
    3232    public DateTimeValue(DateTime value) : base(value) { }
    3333
    3434    public override IDeepCloneable Clone(Cloner cloner) {
    35       DateTimeValue clone = new DateTimeValue(Value);
     35      DateTimeValue clone = new DateTimeValue(value);
    3636      cloner.RegisterClonedObject(this, clone);
    3737      return clone;
     
    4242    }
    4343
    44     public int CompareTo(object obj) {
     44    public virtual int CompareTo(object obj) {
    4545      DateTimeValue other = obj as DateTimeValue;
    4646      if (other != null)
     
    5050    }
    5151
    52     #region IStringConvertibleValue Members
    53     bool IStringConvertibleValue.Validate(string value, out string errorMessage) {
     52    protected virtual bool Validate(string value, out string errorMessage) {
    5453      DateTime val;
    5554      bool valid = DateTime.TryParse(value, out val);
     
    5756      return valid;
    5857    }
    59     string IStringConvertibleValue.GetValue() {
     58    protected virtual string GetValue() {
    6059      return Value.ToString("o");  // round-trip format
    6160    }
    62     bool IStringConvertibleValue.SetValue(string value) {
     61    protected virtual bool SetValue(string value) {
    6362      DateTime val;
    6463      if (DateTime.TryParse(value, out val)) {
     
    6968      }
    7069    }
     70
     71    #region IStringConvertibleValue Members
     72    bool IStringConvertibleValue.Validate(string value, out string errorMessage) {
     73      return Validate(value, out errorMessage);
     74    }
     75    string IStringConvertibleValue.GetValue() {
     76      return GetValue();
     77    }
     78    bool IStringConvertibleValue.SetValue(string value) {
     79      return SetValue(value);
     80    }
    7181    #endregion
    7282  }
  • trunk/sources/HeuristicLab.Data/3.3/DoubleArray.cs

    r3048 r3054  
    2828  [Creatable("Test")]
    2929  [StorableClass]
    30   public sealed class DoubleArray : ValueTypeArray<double>, IStringConvertibleArray {
     30  public class DoubleArray : ValueTypeArray<double>, IStringConvertibleArray {
    3131    public DoubleArray() : base() { }
    3232    public DoubleArray(int length) : base(length) { }
    3333    public DoubleArray(double[] elements) : base(elements) { }
    34     private DoubleArray(DoubleArray elements) : base(elements) { }
    3534
    3635    public override IDeepCloneable Clone(Cloner cloner) {
    37       DoubleArray clone = new DoubleArray(this);
     36      DoubleArray clone = new DoubleArray(array);
    3837      cloner.RegisterClonedObject(this, clone);
    3938      return clone;
    4039    }
    4140
    42     #region IStringConvertibleArray Members
    43     int IStringConvertibleArray.Length {
    44       get { return Length; }
    45       set { Length = value; }
    46     }
    47 
    48     bool IStringConvertibleArray.Validate(string value, out string errorMessage) {
     41    protected virtual bool Validate(string value, out string errorMessage) {
    4942      double val;
    5043      bool valid = double.TryParse(value, out val);
     
    5952      return valid;
    6053    }
    61     string IStringConvertibleArray.GetValue(int index) {
     54    protected virtual string GetValue(int index) {
    6255      return this[index].ToString();
    6356    }
    64     bool IStringConvertibleArray.SetValue(string value, int index) {
     57    protected virtual bool SetValue(string value, int index) {
    6558      double val;
    6659      if (double.TryParse(value, out val)) {
     
    7164      }
    7265    }
     66
     67    #region IStringConvertibleArray Members
     68    int IStringConvertibleArray.Length {
     69      get { return Length; }
     70      set { Length = value; }
     71    }
     72    bool IStringConvertibleArray.Validate(string value, out string errorMessage) {
     73      return Validate(value, out errorMessage);
     74    }
     75    string IStringConvertibleArray.GetValue(int index) {
     76      return GetValue(index);
     77    }
     78    bool IStringConvertibleArray.SetValue(string value, int index) {
     79      return SetValue(value, index);
     80    }
    7381    #endregion
    7482  }
  • trunk/sources/HeuristicLab.Data/3.3/DoubleMatrix.cs

    r3048 r3054  
    2828  [Creatable("Test")]
    2929  [StorableClass]
    30   public sealed class DoubleMatrix : ValueTypeMatrix<double>, IStringConvertibleMatrix {
     30  public class DoubleMatrix : ValueTypeMatrix<double>, IStringConvertibleMatrix {
    3131    public DoubleMatrix() : base() { }
    3232    public DoubleMatrix(int rows, int columns) : base(rows, columns) { }
    3333    public DoubleMatrix(double[,] elements) : base(elements) { }
    34     private DoubleMatrix(DoubleMatrix elements) : base(elements) { }
    3534
    3635    public override IDeepCloneable Clone(Cloner cloner) {
    37       DoubleMatrix clone = new DoubleMatrix(this);
     36      DoubleMatrix clone = new DoubleMatrix(matrix);
    3837      cloner.RegisterClonedObject(this, clone);
    3938      return clone;
    4039    }
    4140
    42     #region IStringConvertibleMatrix Members
    43     int IStringConvertibleMatrix.Rows {
    44       get { return Rows; }
    45       set { Rows = value; }
    46     }
    47     int IStringConvertibleMatrix.Columns {
    48       get { return Columns; }
    49       set { Columns = value; }
    50     }
    51 
    52     bool IStringConvertibleMatrix.Validate(string value, out string errorMessage) {
     41    protected virtual bool Validate(string value, out string errorMessage) {
    5342      double val;
    5443      bool valid = double.TryParse(value, out val);
     
    6352      return valid;
    6453    }
    65     string IStringConvertibleMatrix.GetValue(int rowIndex, int columIndex) {
     54    protected virtual string GetValue(int rowIndex, int columIndex) {
    6655      return this[rowIndex, columIndex].ToString();
    6756    }
    68     bool IStringConvertibleMatrix.SetValue(string value, int rowIndex, int columnIndex) {
     57    protected virtual bool SetValue(string value, int rowIndex, int columnIndex) {
    6958      double val;
    7059      if (double.TryParse(value, out val)) {
     
    7564      }
    7665    }
     66
     67    #region IStringConvertibleMatrix Members
     68    int IStringConvertibleMatrix.Rows {
     69      get { return Rows; }
     70      set { Rows = value; }
     71    }
     72    int IStringConvertibleMatrix.Columns {
     73      get { return Columns; }
     74      set { Columns = value; }
     75    }
     76    bool IStringConvertibleMatrix.Validate(string value, out string errorMessage) {
     77      return Validate(value, out errorMessage);
     78    }
     79    string IStringConvertibleMatrix.GetValue(int rowIndex, int columIndex) {
     80      return GetValue(rowIndex, columIndex);
     81    }
     82    bool IStringConvertibleMatrix.SetValue(string value, int rowIndex, int columnIndex) {
     83      return SetValue(value, rowIndex, columnIndex);
     84    }
    7785    #endregion
    7886  }
  • trunk/sources/HeuristicLab.Data/3.3/DoubleValue.cs

    r3048 r3054  
    2929  [Creatable("Test")]
    3030  [StorableClass]
    31   public sealed class DoubleValue : ValueTypeValue<double>, IComparable, IStringConvertibleValue {
     31  public class DoubleValue : ValueTypeValue<double>, IComparable, IStringConvertibleValue {
    3232    public DoubleValue() : base() { }
    3333    public DoubleValue(double value) : base(value) { }
    3434
    3535    public override IDeepCloneable Clone(Cloner cloner) {
    36       DoubleValue clone = new DoubleValue(Value);
     36      DoubleValue clone = new DoubleValue(value);
    3737      cloner.RegisterClonedObject(this, clone);
    3838      return clone;
     
    4343    }
    4444
    45     public int CompareTo(object obj) {
     45    public virtual int CompareTo(object obj) {
    4646      DoubleValue other = obj as DoubleValue;
    4747      if (other != null)
     
    5151    }
    5252
    53     #region IStringConvertibleValue Members
    54     bool IStringConvertibleValue.Validate(string value, out string errorMessage) {
     53    protected virtual bool Validate(string value, out string errorMessage) {
    5554      double val;
    5655      bool valid = double.TryParse(value, out val);
     
    6564      return valid;
    6665    }
    67     string IStringConvertibleValue.GetValue() {
     66    protected virtual string GetValue() {
    6867      return Value.ToString("r");  // round-trip format
    6968    }
    70     bool IStringConvertibleValue.SetValue(string value) {
     69    protected virtual bool SetValue(string value) {
    7170      double val;
    7271      if (double.TryParse(value, out val)) {
     
    7776      }
    7877    }
     78
     79    #region IStringConvertibleValue Members
     80    bool IStringConvertibleValue.Validate(string value, out string errorMessage) {
     81      return Validate(value, out errorMessage);
     82    }
     83    string IStringConvertibleValue.GetValue() {
     84      return GetValue();
     85    }
     86    bool IStringConvertibleValue.SetValue(string value) {
     87      return SetValue(value);
     88    }
    7989    #endregion
    8090  }
  • trunk/sources/HeuristicLab.Data/3.3/HeuristicLab.Data-3.3.csproj

    r3047 r3054  
    9595    </Reference>
    9696    <Reference Include="System.Data" />
    97     <Reference Include="System.Drawing" />
    98     <Reference Include="System.Windows.Forms" />
    9997    <Reference Include="System.Xml" />
    10098  </ItemGroup>
  • trunk/sources/HeuristicLab.Data/3.3/IntArray.cs

    r3048 r3054  
    2828  [Creatable("Test")]
    2929  [StorableClass]
    30   public sealed class IntArray : ValueTypeArray<int>, IStringConvertibleArray {
     30  public class IntArray : ValueTypeArray<int>, IStringConvertibleArray {
    3131    public IntArray() : base() { }
    3232    public IntArray(int length) : base(length) { }
    3333    public IntArray(int[] elements) : base(elements) { }
    34     private IntArray(IntArray elements) : base(elements) { }
    3534
    3635    public override IDeepCloneable Clone(Cloner cloner) {
    37       IntArray clone = new IntArray(this);
     36      IntArray clone = new IntArray(array);
    3837      cloner.RegisterClonedObject(this, clone);
    3938      return clone;
    4039    }
    4140
    42     #region IStringConvertibleArray Members
    43     int IStringConvertibleArray.Length {
    44       get { return Length; }
    45       set { Length = value; }
    46     }
    47 
    48     bool IStringConvertibleArray.Validate(string value, out string errorMessage) {
     41    protected virtual bool Validate(string value, out string errorMessage) {
    4942      int val;
    5043      bool valid = int.TryParse(value, out val);
     
    5952      return valid;
    6053    }
    61     string IStringConvertibleArray.GetValue(int index) {
     54    protected virtual string GetValue(int index) {
    6255      return this[index].ToString();
    6356    }
    64     bool IStringConvertibleArray.SetValue(string value, int index) {
     57    protected virtual bool SetValue(string value, int index) {
    6558      int val;
    6659      if (int.TryParse(value, out val)) {
     
    7164      }
    7265    }
     66
     67    #region IStringConvertibleArray Members
     68    int IStringConvertibleArray.Length {
     69      get { return Length; }
     70      set { Length = value; }
     71    }
     72    bool IStringConvertibleArray.Validate(string value, out string errorMessage) {
     73      return Validate(value, out errorMessage);
     74    }
     75    string IStringConvertibleArray.GetValue(int index) {
     76      return GetValue(index);
     77    }
     78    bool IStringConvertibleArray.SetValue(string value, int index) {
     79      return SetValue(value, index);
     80    }
    7381    #endregion
    7482  }
  • trunk/sources/HeuristicLab.Data/3.3/IntMatrix.cs

    r3048 r3054  
    2828  [Creatable("Test")]
    2929  [StorableClass]
    30   public sealed class IntMatrix : ValueTypeMatrix<int>, IStringConvertibleMatrix {
     30  public class IntMatrix : ValueTypeMatrix<int>, IStringConvertibleMatrix {
    3131    public IntMatrix() : base() { }
    3232    public IntMatrix(int rows, int columns) : base(rows, columns) { }
    3333    public IntMatrix(int[,] elements) : base(elements) { }
    34     private IntMatrix(IntMatrix elements) : base(elements) { }
    3534
    3635    public override IDeepCloneable Clone(Cloner cloner) {
    37       IntMatrix clone = new IntMatrix(this);
     36      IntMatrix clone = new IntMatrix(matrix);
    3837      cloner.RegisterClonedObject(this, clone);
    3938      return clone;
    4039    }
    4140
    42     #region IStringConvertibleMatrix Members
    43     int IStringConvertibleMatrix.Rows {
    44       get { return Rows; }
    45       set { Rows = value; }
    46     }
    47     int IStringConvertibleMatrix.Columns {
    48       get { return Columns; }
    49       set { Columns = value; }
    50     }
    51 
    52     bool IStringConvertibleMatrix.Validate(string value, out string errorMessage) {
     41    protected virtual bool Validate(string value, out string errorMessage) {
    5342      int val;
    5443      bool valid = int.TryParse(value, out val);
     
    6352      return valid;
    6453    }
    65     string IStringConvertibleMatrix.GetValue(int rowIndex, int columIndex) {
     54    protected virtual string GetValue(int rowIndex, int columIndex) {
    6655      return this[rowIndex, columIndex].ToString();
    6756    }
    68     bool IStringConvertibleMatrix.SetValue(string value, int rowIndex, int columnIndex) {
     57    protected virtual bool SetValue(string value, int rowIndex, int columnIndex) {
    6958      int val;
    7059      if (int.TryParse(value, out val)) {
     
    7564      }
    7665    }
     66
     67    #region IStringConvertibleMatrix Members
     68    int IStringConvertibleMatrix.Rows {
     69      get { return Rows; }
     70      set { Rows = value; }
     71    }
     72    int IStringConvertibleMatrix.Columns {
     73      get { return Columns; }
     74      set { Columns = value; }
     75    }
     76    bool IStringConvertibleMatrix.Validate(string value, out string errorMessage) {
     77      return Validate(value, out errorMessage);
     78    }
     79    string IStringConvertibleMatrix.GetValue(int rowIndex, int columIndex) {
     80      return GetValue(rowIndex, columIndex);
     81    }
     82    bool IStringConvertibleMatrix.SetValue(string value, int rowIndex, int columnIndex) {
     83      return SetValue(value, rowIndex, columnIndex);
     84    }
    7785    #endregion
    7886  }
  • trunk/sources/HeuristicLab.Data/3.3/IntValue.cs

    r3048 r3054  
    2929  [Creatable("Test")]
    3030  [StorableClass]
    31   public sealed class IntValue : ValueTypeValue<int>, IComparable, IStringConvertibleValue {
     31  public class IntValue : ValueTypeValue<int>, IComparable, IStringConvertibleValue {
    3232    public IntValue() : base() { }
    3333    public IntValue(int value) : base(value) { }
    3434
    3535    public override IDeepCloneable Clone(Cloner cloner) {
    36       IntValue clone = new IntValue(Value);
     36      IntValue clone = new IntValue(value);
    3737      cloner.RegisterClonedObject(this, clone);
    3838      return clone;
    3939    }
    4040
    41     public int CompareTo(object obj) {
     41    public virtual int CompareTo(object obj) {
    4242      IntValue other = obj as IntValue;
    4343      if (other != null)
     
    4747    }
    4848
    49     #region IStringConvertibleValue Members
    50     bool IStringConvertibleValue.Validate(string value, out string errorMessage) {
     49    protected virtual bool Validate(string value, out string errorMessage) {
    5150      int val;
    5251      bool valid = int.TryParse(value, out val);
     
    6160      return valid;
    6261    }
    63     string IStringConvertibleValue.GetValue() {
     62    protected virtual string GetValue() {
    6463      return Value.ToString();
    6564    }
    66     bool IStringConvertibleValue.SetValue(string value) {
     65    protected virtual bool SetValue(string value) {
    6766      int val;
    6867      if (int.TryParse(value, out val)) {
     
    7372      }
    7473    }
     74
     75    #region IStringConvertibleValue Members
     76    bool IStringConvertibleValue.Validate(string value, out string errorMessage) {
     77      return Validate(value, out errorMessage);
     78    }
     79    string IStringConvertibleValue.GetValue() {
     80      return GetValue();
     81    }
     82    bool IStringConvertibleValue.SetValue(string value) {
     83      return SetValue(value);
     84    }
    7585    #endregion
    7686  }
  • trunk/sources/HeuristicLab.Data/3.3/StringArray.cs

    r3048 r3054  
    3131  [Creatable("Test")]
    3232  [StorableClass]
    33   public sealed class StringArray : Item, IEnumerable, IStringConvertibleArray {
     33  public class StringArray : Item, IEnumerable, IStringConvertibleArray {
    3434    [Storable]
    35     private string[] array;
     35    protected string[] array;
    3636
    37     public int Length {
     37    public virtual int Length {
    3838      get { return array.Length; }
    39       private set {
     39      protected set {
    4040        if (value != Length) {
    4141          Array.Resize<string>(ref array, value);
     
    4444      }
    4545    }
    46     public string this[int index] {
     46    public virtual string this[int index] {
    4747      get { return array[index]; }
    4848      set {
     
    7070        array[i] = elements[i] == null ? string.Empty : elements[i];
    7171    }
    72     private StringArray(StringArray elements) {
    73       if (elements == null) throw new ArgumentNullException();
    74       array = (string[])elements.array.Clone();
    75     }
    7672
    7773    public override IDeepCloneable Clone(Cloner cloner) {
    78       StringArray clone = new StringArray(this);
     74      StringArray clone = new StringArray();
    7975      cloner.RegisterClonedObject(this, clone);
     76      clone.array = (string[])array.Clone();
    8077      return clone;
    8178    }
     
    9390    }
    9491
    95     public IEnumerator GetEnumerator() {
     92    public virtual IEnumerator GetEnumerator() {
    9693      return array.GetEnumerator();
    9794    }
    9895
    99     #region IStringConvertibleArray Members
    100     int IStringConvertibleArray.Length {
    101       get { return Length; }
    102       set { Length = value; }
    103     }
    104 
    105     bool IStringConvertibleArray.Validate(string value, out string errorMessage) {
     96    protected virtual bool Validate(string value, out string errorMessage) {
    10697      if (value == null) {
    10798        errorMessage = "Invalid Value (string must not be null)";
     
    112103      }
    113104    }
    114     string IStringConvertibleArray.GetValue(int index) {
     105    protected virtual string GetValue(int index) {
    115106      return this[index];
    116107    }
    117     bool IStringConvertibleArray.SetValue(string value, int index) {
     108    protected virtual bool SetValue(string value, int index) {
    118109      if (value != null) {
    119110        this[index] = value;
     
    123114      }
    124115    }
     116
    125117    public event EventHandler<EventArgs<int>> ItemChanged;
    126     private void OnItemChanged(int index) {
     118    protected virtual void OnItemChanged(int index) {
    127119      if (ItemChanged != null)
    128120        ItemChanged(this, new EventArgs<int>(index));
     
    130122    }
    131123    public event EventHandler Reset;
    132     private void OnReset() {
     124    protected virtual void OnReset() {
    133125      if (Reset != null)
    134126        Reset(this, EventArgs.Empty);
    135127      OnToStringChanged();
    136128    }
     129
     130    #region IStringConvertibleArray Members
     131    int IStringConvertibleArray.Length {
     132      get { return Length; }
     133      set { Length = value; }
     134    }
     135    bool IStringConvertibleArray.Validate(string value, out string errorMessage) {
     136      return Validate(value, out errorMessage);
     137    }
     138    string IStringConvertibleArray.GetValue(int index) {
     139      return GetValue(index);
     140    }
     141    bool IStringConvertibleArray.SetValue(string value, int index) {
     142      return SetValue(value, index);
     143    }
    137144    #endregion
    138145  }
  • trunk/sources/HeuristicLab.Data/3.3/StringMatrix.cs

    r3048 r3054  
    3131  [Creatable("Test")]
    3232  [StorableClass]
    33   public sealed class StringMatrix : Item, IEnumerable, IStringConvertibleMatrix {
     33  public class StringMatrix : Item, IEnumerable, IStringConvertibleMatrix {
    3434    [Storable]
    35     private string[,] array;
     35    protected string[,] matrix;
    3636
    37     public int Rows {
    38       get { return array.GetLength(0); }
    39       private set {
     37    public virtual int Rows {
     38      get { return matrix.GetLength(0); }
     39      protected set {
    4040        if (value != Rows) {
    41           string[,] newArray = new string[value, Columns];
    42           Array.Copy(array, newArray, Math.Min(value * Columns, array.Length));
    43           array = newArray;
     41          string[,] newMatrix = new string[value, Columns];
     42          Array.Copy(matrix, newMatrix, Math.Min(value * Columns, matrix.Length));
     43          matrix = newMatrix;
    4444          OnReset();
    4545        }
    4646      }
    4747    }
    48     public int Columns {
    49       get { return array.GetLength(1); }
    50       private set {
     48    public virtual int Columns {
     49      get { return matrix.GetLength(1); }
     50      protected set {
    5151        if (value != Columns) {
    52           string[,] newArray = new string[Rows, value];
     52          string[,] newMatrix = new string[Rows, value];
    5353          for (int i = 0; i < Rows; i++)
    54             Array.Copy(array, i * Columns, newArray, i * value, Math.Min(value, Columns));
    55           array = newArray;
     54            Array.Copy(matrix, i * Columns, newMatrix, i * value, Math.Min(value, Columns));
     55          matrix = newMatrix;
    5656          OnReset();
    5757        }
    5858      }
    5959    }
    60     public string this[int rowIndex, int columnIndex] {
    61       get { return array[rowIndex, columnIndex]; }
     60    public virtual string this[int rowIndex, int columnIndex] {
     61      get { return matrix[rowIndex, columnIndex]; }
    6262      set {
    63         if (value != array[rowIndex, columnIndex]) {
    64           if ((value != null) || (array[rowIndex, columnIndex] != string.Empty)) {
    65             array[rowIndex, columnIndex] = value != null ? value : string.Empty;
     63        if (value != matrix[rowIndex, columnIndex]) {
     64          if ((value != null) || (matrix[rowIndex, columnIndex] != string.Empty)) {
     65            matrix[rowIndex, columnIndex] = value != null ? value : string.Empty;
    6666            OnItemChanged(rowIndex, columnIndex);
    6767          }
     
    7171
    7272    public StringMatrix() {
    73       array = new string[0, 0];
     73      matrix = new string[0, 0];
    7474    }
    7575    public StringMatrix(int rows, int columns) {
    76       array = new string[rows, columns];
    77       for (int i = 0; i < array.GetLength(0); i++) {
    78         for (int j = 0; j < array.GetLength(1); j++)
    79           array[i, j] = string.Empty;
     76      matrix = new string[rows, columns];
     77      for (int i = 0; i < matrix.GetLength(0); i++) {
     78        for (int j = 0; j < matrix.GetLength(1); j++)
     79          matrix[i, j] = string.Empty;
    8080      }
    8181    }
    8282    public StringMatrix(string[,] elements) {
    8383      if (elements == null) throw new ArgumentNullException();
    84       array = new string[elements.GetLength(0), elements.GetLength(1)];
    85       for (int i = 0; i < array.GetLength(0); i++) {
    86         for (int j = 0; j < array.GetLength(1); j++)
    87           array[i, j] = elements[i, j] == null ? string.Empty : elements[i, j];
     84      matrix = new string[elements.GetLength(0), elements.GetLength(1)];
     85      for (int i = 0; i < matrix.GetLength(0); i++) {
     86        for (int j = 0; j < matrix.GetLength(1); j++)
     87          matrix[i, j] = elements[i, j] == null ? string.Empty : elements[i, j];
    8888      }
    89     }
    90     private StringMatrix(StringMatrix elements) {
    91       if (elements == null) throw new ArgumentNullException();
    92       array = (string[,])elements.array.Clone();
    9389    }
    9490
    9591    public override IDeepCloneable Clone(Cloner cloner) {
    96       StringMatrix clone = new StringMatrix(this);
     92      StringMatrix clone = new StringMatrix();
    9793      cloner.RegisterClonedObject(this, clone);
     94      clone.matrix = (string[,])matrix.Clone();
    9895      return clone;
    9996    }
     
    10299      StringBuilder sb = new StringBuilder();
    103100      sb.Append("[");
    104       if (array.Length > 0) {
     101      if (matrix.Length > 0) {
    105102        for (int i = 0; i < Rows; i++) {
    106           sb.Append("[").Append(array[i, 0]);
     103          sb.Append("[").Append(matrix[i, 0]);
    107104          for (int j = 1; j < Columns; j++)
    108             sb.Append(";").Append(array[i, j]);
     105            sb.Append(";").Append(matrix[i, j]);
    109106          sb.Append("]");
    110107        }
     
    114111    }
    115112
    116     public IEnumerator GetEnumerator() {
    117       return array.GetEnumerator();
     113    public virtual IEnumerator GetEnumerator() {
     114      return matrix.GetEnumerator();
     115    }
     116
     117    protected virtual bool Validate(string value, out string errorMessage) {
     118      if (value == null) {
     119        errorMessage = "Invalid Value (string must not be null)";
     120        return false;
     121      } else {
     122        errorMessage = string.Empty;
     123        return true;
     124      }
     125    }
     126    protected virtual string GetValue(int rowIndex, int columIndex) {
     127      return this[rowIndex, columIndex];
     128    }
     129    protected virtual bool SetValue(string value, int rowIndex, int columnIndex) {
     130      if (value != null) {
     131        this[rowIndex, columnIndex] = value;
     132        return true;
     133      } else {
     134        return false;
     135      }
     136    }
     137
     138    public event EventHandler<EventArgs<int, int>> ItemChanged;
     139    protected virtual void OnItemChanged(int rowIndex, int columnIndex) {
     140      if (ItemChanged != null)
     141        ItemChanged(this, new EventArgs<int, int>(rowIndex, columnIndex));
     142      OnToStringChanged();
     143    }
     144    public event EventHandler Reset;
     145    protected virtual void OnReset() {
     146      if (Reset != null)
     147        Reset(this, EventArgs.Empty);
     148      OnToStringChanged();
    118149    }
    119150
     
    127158      set { Columns = value; }
    128159    }
    129 
    130160    bool IStringConvertibleMatrix.Validate(string value, out string errorMessage) {
    131       if (value == null) {
    132         errorMessage = "Invalid Value (string must not be null)";
    133         return false;
    134       } else {
    135         errorMessage = string.Empty;
    136         return true;
    137       }
     161      return Validate(value, out errorMessage);
    138162    }
    139163    string IStringConvertibleMatrix.GetValue(int rowIndex, int columIndex) {
    140       return this[rowIndex, columIndex];
     164      return GetValue(rowIndex, columIndex);
    141165    }
    142166    bool IStringConvertibleMatrix.SetValue(string value, int rowIndex, int columnIndex) {
    143       if (value != null) {
    144         this[rowIndex, columnIndex] = value;
    145         return true;
    146       } else {
    147         return false;
    148       }
    149     }
    150     public event EventHandler<EventArgs<int, int>> ItemChanged;
    151     private void OnItemChanged(int rowIndex, int columnIndex) {
    152       if (ItemChanged != null)
    153         ItemChanged(this, new EventArgs<int, int>(rowIndex, columnIndex));
    154       OnToStringChanged();
    155     }
    156     public event EventHandler Reset;
    157     private void OnReset() {
    158       if (Reset != null)
    159         Reset(this, EventArgs.Empty);
    160       OnToStringChanged();
     167      return SetValue(value, rowIndex, columnIndex);
    161168    }
    162169    #endregion
  • trunk/sources/HeuristicLab.Data/3.3/StringValue.cs

    r3048 r3054  
    2828  [Creatable("Test")]
    2929  [StorableClass]
    30   public sealed class StringValue : Item, IComparable, IStringConvertibleValue {
     30  public class StringValue : Item, IComparable, IStringConvertibleValue {
    3131    [Storable]
    32     private string value;
    33     public string Value {
     32    protected string value;
     33    public virtual string Value {
    3434      get { return value; }
    3535      set {
     
    5151
    5252    public override IDeepCloneable Clone(Cloner cloner) {
    53       StringValue clone = new StringValue(Value);
     53      StringValue clone = new StringValue(value);
    5454      cloner.RegisterClonedObject(this, clone);
    5555      return clone;
     
    6060    }
    6161
    62     public int CompareTo(object obj) {
     62    public virtual int CompareTo(object obj) {
    6363      StringValue other = obj as StringValue;
    6464      if (other != null)
     
    6969
    7070    public event EventHandler ValueChanged;
    71     private void OnValueChanged() {
     71    protected virtual void OnValueChanged() {
    7272      if (ValueChanged != null)
    7373        ValueChanged(this, EventArgs.Empty);
     
    7575    }
    7676
    77     #region IStringConvertibleValue Members
    78     bool IStringConvertibleValue.Validate(string value, out string errorMessage) {
     77    protected virtual bool Validate(string value, out string errorMessage) {
    7978      if (value == null) {
    8079        errorMessage = "Invalid Value (string must not be null)";
     
    8584      }
    8685    }
    87     string IStringConvertibleValue.GetValue() {
     86    protected virtual string GetValue() {
    8887      return Value;
    8988    }
    90     bool IStringConvertibleValue.SetValue(string value) {
     89    protected virtual bool SetValue(string value) {
    9190      if (value != null) {
    9291        Value = value;
     
    9695      }
    9796    }
     97
     98    #region IStringConvertibleValue Members
     99    bool IStringConvertibleValue.Validate(string value, out string errorMessage) {
     100      return Validate(value, out errorMessage);
     101    }
     102    string IStringConvertibleValue.GetValue() {
     103      return GetValue();
     104    }
     105    bool IStringConvertibleValue.SetValue(string value) {
     106      return SetValue(value);
     107    }
    98108    #endregion
    99109  }
  • trunk/sources/HeuristicLab.Data/3.3/TimeSpanValue.cs

    r3048 r3054  
    2929  [Creatable("Test")]
    3030  [StorableClass]
    31   public sealed class TimeSpanValue : ValueTypeValue<TimeSpan>, IComparable, IStringConvertibleValue {
     31  public class TimeSpanValue : ValueTypeValue<TimeSpan>, IComparable, IStringConvertibleValue {
    3232    public TimeSpanValue() : base() { }
    3333    public TimeSpanValue(TimeSpan value) : base(value) { }
    3434
    3535    public override IDeepCloneable Clone(Cloner cloner) {
    36       TimeSpanValue clone = new TimeSpanValue(Value);
     36      TimeSpanValue clone = new TimeSpanValue(value);
    3737      cloner.RegisterClonedObject(this, clone);
    3838      return clone;
    3939    }
    4040
    41     public int CompareTo(object obj) {
     41    public virtual int CompareTo(object obj) {
    4242      TimeSpanValue other = obj as TimeSpanValue;
    4343      if (other != null)
     
    4747    }
    4848
    49     #region IStringConvertibleValue Members
    50     bool IStringConvertibleValue.Validate(string value, out string errorMessage) {
     49    protected virtual bool Validate(string value, out string errorMessage) {
    5150      TimeSpan val;
    5251      bool valid = TimeSpan.TryParse(value, out val);
     
    6160      return valid;
    6261    }
    63     string IStringConvertibleValue.GetValue() {
     62    protected virtual string GetValue() {
    6463      return Value.ToString();
    6564    }
    66     bool IStringConvertibleValue.SetValue(string value) {
     65    protected virtual bool SetValue(string value) {
    6766      TimeSpan val;
    6867      if (TimeSpan.TryParse(value, out val)) {
     
    7372      }
    7473    }
     74
     75    #region IStringConvertibleValue Members
     76    bool IStringConvertibleValue.Validate(string value, out string errorMessage) {
     77      return Validate(value, out errorMessage);
     78    }
     79    string IStringConvertibleValue.GetValue() {
     80      return GetValue();
     81    }
     82    bool IStringConvertibleValue.SetValue(string value) {
     83      return SetValue(value);
     84    }
    7585    #endregion
    7686  }
  • trunk/sources/HeuristicLab.Data/3.3/ValueTypeArray.cs

    r3048 r3054  
    2828
    2929namespace HeuristicLab.Data {
    30   [Item("ValueTypeArray<T>", "A base class for representing arrays of value types.")]
     30  [Item("ValueTypeArray<T>", "An abstract base class for representing arrays of value types.")]
    3131  [StorableClass]
    32   public class ValueTypeArray<T> : Item, IEnumerable where T : struct {
     32  public abstract class ValueTypeArray<T> : Item, IEnumerable where T : struct {
    3333    [Storable]
    34     private T[] array;
     34    protected T[] array;
    3535
    36     public int Length {
     36    public virtual int Length {
    3737      get { return array.Length; }
    3838      protected set {
     
    4343      }
    4444    }
    45     public T this[int index] {
     45    public virtual T this[int index] {
    4646      get { return array[index]; }
    4747      set {
     
    5353    }
    5454
    55     public ValueTypeArray() {
     55    protected ValueTypeArray() {
    5656      array = new T[0];
    5757    }
    58     public ValueTypeArray(int length) {
     58    protected ValueTypeArray(int length) {
    5959      array = new T[length];
    6060    }
    61     public ValueTypeArray(T[] elements) {
     61    protected ValueTypeArray(T[] elements) {
    6262      if (elements == null) throw new ArgumentNullException();
    6363      array = (T[])elements.Clone();
    64     }
    65     protected ValueTypeArray(ValueTypeArray<T> elements) {
    66       if (elements == null) throw new ArgumentNullException();
    67       array = (T[])elements.array.Clone();
    6864    }
    6965
     
    8682    }
    8783
    88     public IEnumerator GetEnumerator() {
     84    public virtual IEnumerator GetEnumerator() {
    8985      return array.GetEnumerator();
    9086    }
    9187
    9288    public event EventHandler<EventArgs<int>> ItemChanged;
    93     private void OnItemChanged(int index) {
     89    protected virtual void OnItemChanged(int index) {
    9490      if (ItemChanged != null)
    9591        ItemChanged(this, new EventArgs<int>(index));
     
    9793    }
    9894    public event EventHandler Reset;
    99     private void OnReset() {
     95    protected virtual void OnReset() {
    10096      if (Reset != null)
    10197        Reset(this, EventArgs.Empty);
  • trunk/sources/HeuristicLab.Data/3.3/ValueTypeMatrix.cs

    r3048 r3054  
    2828
    2929namespace HeuristicLab.Data {
    30   [Item("ValueTypeMatrix<T>", "A base class for representing matrices of value types.")]
     30  [Item("ValueTypeMatrix<T>", "An abstract base class for representing matrices of value types.")]
    3131  [StorableClass]
    32   public class ValueTypeMatrix<T> : Item, IEnumerable where T : struct {
     32  public abstract class ValueTypeMatrix<T> : Item, IEnumerable where T : struct {
    3333    [Storable]
    34     private T[,] array;
     34    protected T[,] matrix;
    3535
    36     public int Rows {
    37       get { return array.GetLength(0); }
     36    public virtual int Rows {
     37      get { return matrix.GetLength(0); }
    3838      protected set {
    3939        if (value != Rows) {
    4040          T[,] newArray = new T[value, Columns];
    41           Array.Copy(array, newArray, Math.Min(value * Columns, array.Length));
    42           array = newArray;
     41          Array.Copy(matrix, newArray, Math.Min(value * Columns, matrix.Length));
     42          matrix = newArray;
    4343          OnReset();
    4444        }
    4545      }
    4646    }
    47     public int Columns {
    48       get { return array.GetLength(1); }
     47    public virtual int Columns {
     48      get { return matrix.GetLength(1); }
    4949      protected set {
    5050        if (value != Columns) {
    5151          T[,] newArray = new T[Rows, value];
    5252          for (int i = 0; i < Rows; i++)
    53             Array.Copy(array, i * Columns, newArray, i * value, Math.Min(value, Columns));
    54           array = newArray;
     53            Array.Copy(matrix, i * Columns, newArray, i * value, Math.Min(value, Columns));
     54          matrix = newArray;
    5555          OnReset();
    5656        }
    5757      }
    5858    }
    59     public T this[int rowIndex, int columnIndex] {
    60       get { return array[rowIndex, columnIndex]; }
     59    public virtual T this[int rowIndex, int columnIndex] {
     60      get { return matrix[rowIndex, columnIndex]; }
    6161      set {
    62         if (!value.Equals(array[rowIndex, columnIndex])) {
    63           array[rowIndex, columnIndex] = value;
     62        if (!value.Equals(matrix[rowIndex, columnIndex])) {
     63          matrix[rowIndex, columnIndex] = value;
    6464          OnItemChanged(rowIndex, columnIndex);
    6565        }
     
    6767    }
    6868
    69     public ValueTypeMatrix() {
    70       array = new T[0, 0];
     69    protected ValueTypeMatrix() {
     70      matrix = new T[0, 0];
    7171    }
    72     public ValueTypeMatrix(int rows, int columns) {
    73       array = new T[rows, columns];
     72    protected ValueTypeMatrix(int rows, int columns) {
     73      matrix = new T[rows, columns];
    7474    }
    75     public ValueTypeMatrix(T[,] elements) {
     75    protected ValueTypeMatrix(T[,] elements) {
    7676      if (elements == null) throw new ArgumentNullException();
    77       array = (T[,])elements.Clone();
    78     }
    79     protected ValueTypeMatrix(ValueTypeMatrix<T> elements) {
    80       if (elements == null) throw new ArgumentNullException();
    81       array = (T[,])elements.array.Clone();
     77      matrix = (T[,])elements.Clone();
    8278    }
    8379
    8480    public override IDeepCloneable Clone(Cloner cloner) {
    8581      ValueTypeMatrix<T> clone = (ValueTypeMatrix<T>)base.Clone(cloner);
    86       clone.array = (T[,])array.Clone();
     82      clone.matrix = (T[,])matrix.Clone();
    8783      return clone;
    8884    }
     
    9187      StringBuilder sb = new StringBuilder();
    9288      sb.Append("[");
    93       if (array.Length > 0) {
     89      if (matrix.Length > 0) {
    9490        for (int i = 0; i < Rows; i++) {
    95           sb.Append("[").Append(array[i, 0].ToString());
     91          sb.Append("[").Append(matrix[i, 0].ToString());
    9692          for (int j = 1; j < Columns; j++)
    97             sb.Append(";").Append(array[i, j].ToString());
     93            sb.Append(";").Append(matrix[i, j].ToString());
    9894          sb.Append("]");
    9995        }
     
    10399    }
    104100
    105     public IEnumerator GetEnumerator() {
    106       return array.GetEnumerator();
     101    public virtual IEnumerator GetEnumerator() {
     102      return matrix.GetEnumerator();
    107103    }
    108104
    109105    public event EventHandler<EventArgs<int, int>> ItemChanged;
    110     private void OnItemChanged(int rowIndex, int columnIndex) {
     106    protected virtual void OnItemChanged(int rowIndex, int columnIndex) {
    111107      if (ItemChanged != null)
    112108        ItemChanged(this, new EventArgs<int, int>(rowIndex, columnIndex));
     
    114110    }
    115111    public event EventHandler Reset;
    116     private void OnReset() {
     112    protected virtual void OnReset() {
    117113      if (Reset != null)
    118114        Reset(this, EventArgs.Empty);
  • trunk/sources/HeuristicLab.Data/3.3/ValueTypeValue.cs

    r3048 r3054  
    2525
    2626namespace HeuristicLab.Data {
    27   [Item("ValueTypeValue<T>", "A base class for representing value types.")]
     27  [Item("ValueTypeValue<T>", "An abstract base class for representing values of value types.")]
    2828  [StorableClass]
    29   public class ValueTypeValue<T> : Item where T : struct {
     29  public abstract class ValueTypeValue<T> : Item where T : struct {
    3030    [Storable]
    31     private T value;
    32     public T Value {
     31    protected T value;
     32    public virtual T Value {
    3333      get { return value; }
    3434      set {
     
    4040    }
    4141
    42     public ValueTypeValue() {
     42    protected ValueTypeValue() {
    4343      this.value = default(T);
    4444    }
    45     public ValueTypeValue(T value) {
     45    protected ValueTypeValue(T value) {
    4646      this.value = value;
    4747    }
  • trunk/sources/HeuristicLab.Encodings.BinaryVectorEncoding/3.3/HeuristicLab.Encodings.BinaryVectorEncoding-3.3.csproj

    r3053 r3054  
    8686  <ItemGroup>
    8787    <Compile Include="HeuristicLabEncodingsBinaryVectorEncodingPlugin.cs" />
     88    <Compile Include="BinaryVector.cs" />
    8889    <Compile Include="Interfaces\IBinaryVectorCreator.cs" />
    8990    <Compile Include="Interfaces\IBinaryVectorCrossover.cs" />
  • trunk/sources/HeuristicLab.Encodings.IntegerVectorEncoding/3.3/HeuristicLab.Encodings.IntegerVectorEncoding-3.3.csproj

    r3053 r3054  
    9696      <SubType>Code</SubType>
    9797    </Compile>
     98    <Compile Include="IntegerVector.cs" />
    9899    <Compile Include="Properties\AssemblyInfo.cs" />
    99100    <Compile Include="IntVectorCreator.cs" />
  • trunk/sources/HeuristicLab.Encodings.PermutationEncoding/3.3/Permutation.cs

    r3053 r3054  
    2020#endregion
    2121
    22 using System;
    23 using System.Text;
    24 using HeuristicLab.Common;
    2522using HeuristicLab.Core;
    2623using HeuristicLab.Data;
     
    3128  [Item("Permutation", "Represents a permutation of integer values.")]
    3229  [Creatable("Test")]
    33   public sealed class Permutation : ValueTypeArray<int>, IStringConvertibleArray {
     30  public class Permutation : IntArray {
    3431    public Permutation() : base() { }
    3532    public Permutation(int length)
     
    4239      Randomize(random);
    4340    }
    44     public Permutation(int[] elements)
    45       : base(elements) {
     41    public Permutation(int[] elements) : base(elements) { }
     42    public Permutation(IntArray elements)
     43      : this(elements.Length) {
     44      for (int i = 0; i < array.Length; i++)
     45        array[i] = elements[i];
    4646    }
    47     private Permutation(Permutation elements) : base(elements) { }
    4847
    4948    public override IDeepCloneable Clone(Cloner cloner) {
    50       Permutation clone = new Permutation(this);
     49      Permutation clone = new Permutation(array);
    5150      cloner.RegisterClonedObject(this, clone);
    5251      return clone;
    5352    }
    5453
    55     public bool Validate() {
     54    public virtual bool Validate() {
    5655      bool[] values = new bool[Length];
    5756      int value;
     
    6867    }
    6968
    70     public void Randomize(IRandom random, int startIndex, int length) {  // Knuth shuffle
    71       int index1, index2;
    72       int val;
    73       for (int i = length - 1; i > 0; i--) {
    74         index1 = startIndex + i;
    75         index2 = startIndex + random.Next(i + 1);
    76         if (index1 != index2) {
    77           val = this[index1];
    78           this[index1] = this[index2];
    79           this[index2] = val;
     69    public virtual void Randomize(IRandom random, int startIndex, int length) {
     70      if (length > 1) {
     71        // Knuth shuffle
     72        int index1, index2;
     73        int val;
     74        for (int i = length - 1; i > 0; i--) {
     75          index1 = startIndex + i;
     76          index2 = startIndex + random.Next(i + 1);
     77          if (index1 != index2) {
     78            val = array[index1];
     79            array[index1] = array[index2];
     80            array[index2] = val;
     81          }
    8082        }
     83        OnReset();
    8184      }
    8285    }
     
    8588    }
    8689
    87     public int GetCircular(int position) {
     90    public virtual int GetCircular(int position) {
    8891      if (position >= Length) position = position % Length;
    8992      while (position < 0) position += Length;
    9093      return this[position];
    9194    }
    92 
    93     #region IStringConvertibleArrayData Members
    94     int IStringConvertibleArray.Length {
    95       get { return Length; }
    96       set { Length = value; }
    97     }
    98 
    99     bool IStringConvertibleArray.Validate(string value, out string errorMessage) {
    100       int val;
    101       bool valid = int.TryParse(value, out val);
    102       errorMessage = string.Empty;
    103       if (!valid) {
    104         StringBuilder sb = new StringBuilder();
    105         sb.Append("Invalid Value (Valid Value Format: \"");
    106         sb.Append(FormatPatterns.GetIntFormatPattern());
    107         sb.Append("\")");
    108         errorMessage = sb.ToString();
    109       }
    110       return valid;
    111     }
    112     string IStringConvertibleArray.GetValue(int index) {
    113       return this[index].ToString();
    114     }
    115     bool IStringConvertibleArray.SetValue(string value, int index) {
    116       int val;
    117       if (int.TryParse(value, out val)) {
    118         this[index] = val;
    119         return true;
    120       } else {
    121         return false;
    122       }
    123     }
    124     #endregion
    12595  }
    12696}
  • trunk/sources/HeuristicLab.Encodings.RealVectorEncoding/3.3/HeuristicLab.Encodings.RealVectorEncoding-3.3.csproj

    r3053 r3054  
    103103    <Compile Include="Crossovers\UniformSomePositionsArithmeticCrossover.cs" />
    104104    <Compile Include="HeuristicLabEncodingsRealVectorEncodingPlugin.cs" />
     105    <Compile Include="RealVector.cs" />
    105106    <Compile Include="Manipulators\BreederGeneticAlgorithmManipulator.cs" />
    106107    <Compile Include="Manipulators\PolynomialAllPositionManipulator.cs" />
Note: See TracChangeset for help on using the changeset viewer.