Changeset 11742 for branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/Sequence.cs
- Timestamp:
- 01/09/15 14:57:28 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Problems.GrammaticalOptimization/HeuristicLab.Problems.GrammaticalOptimization/Sequence.cs
r11732 r11742 46 46 } 47 47 48 private Sequence( ) {49 this.symbols = new char[max Idx + 1];48 private Sequence(int maxLength) { 49 this.symbols = new char[maxLength]; 50 50 } 51 51 52 52 // create a sequence from a character 53 53 public Sequence(char ch) 54 : this() { 54 : this(ch, maxIdx + 1) { 55 } 56 57 protected Sequence(char ch, int maxLength) 58 : this(maxLength) { 55 59 this.len = 1; 56 60 symbols[0] = ch; … … 61 65 62 66 // 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) { 65 70 if (string.IsNullOrEmpty(s)) throw new ArgumentException(); 66 71 if (s.Length > (maxIdx + 1)) throw new ArgumentException(); … … 77 82 78 83 // 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) { 81 87 this.len = original.len; 82 88 Array.Copy(original.symbols, this.symbols, len); … … 128 134 if (startIdx >= this.len) throw new ArgumentException(); 129 135 if (startIdx + len > this.len) throw new ArgumentException(); 130 var subsequence = new Sequence { len = len };136 var subsequence = new Sequence(maxIdx + 1) { len = len }; 131 137 132 138 Array.Copy(this.symbols, startIdx, subsequence.symbols, 0, len);
Note: See TracChangeset
for help on using the changeset viewer.