Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/09/15 14:57:28 (9 years ago)
Author:
gkronber
Message:

#2283 refactoring

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/Sequence.cs

    r11732 r11742  
    4646    }
    4747
    48     private Sequence() {
    49       this.symbols = new char[maxIdx + 1];
     48    private Sequence(int maxLength) {
     49      this.symbols = new char[maxLength];
    5050    }
    5151
    5252    // create a sequence from a character
    5353    public Sequence(char ch)
    54       : this() {
     54      : this(ch, maxIdx + 1) {
     55    }
     56
     57    protected Sequence(char ch, int maxLength)
     58      : this(maxLength) {
    5559      this.len = 1;
    5660      symbols[0] = ch;
     
    6165
    6266    // create a sequence from a string
    63     public Sequence(string s)
    64       : this() {
     67    public Sequence(string s) : this(s, maxIdx + 1) { }
     68    protected Sequence(string s, int maxLength)
     69      : this(maxLength) {
    6570      if (string.IsNullOrEmpty(s)) throw new ArgumentException();
    6671      if (s.Length > (maxIdx + 1)) throw new ArgumentException();
     
    7782
    7883    // cloning ctor
    79     public Sequence(Sequence original)
    80       : this() {
     84    public Sequence(Sequence original) : this(original, maxIdx + 1) { }
     85    protected Sequence(Sequence original, int maxLength)
     86      : this(maxLength) {
    8187      this.len = original.len;
    8288      Array.Copy(original.symbols, this.symbols, len);
     
    128134      if (startIdx >= this.len) throw new ArgumentException();
    129135      if (startIdx + len > this.len) throw new ArgumentException();
    130       var subsequence = new Sequence { len = len };
     136      var subsequence = new Sequence(maxIdx + 1) { len = len };
    131137
    132138      Array.Copy(this.symbols, startIdx, subsequence.symbols, 0, len);
Note: See TracChangeset for help on using the changeset viewer.