using System; namespace HeuristicLab.Problems.GrammaticalOptimization { public class ReadonlySequence : Sequence { public ReadonlySequence(string s) : base(s, s.Length) { } public ReadonlySequence(char ch) : base(ch, 1) { } public ReadonlySequence(Sequence s) : base(s, s.Length) { } public override void ReplaceAt(int position, int len, Sequence replacement) { throw new NotSupportedException(); } public override bool Equals(object obj) { var other = obj as Sequence; if (other == null) return false; if (other.Length != this.Length) return false; for (int i = 0; i < Length; i++) if (other[i] != this[i]) return false; // length and all symbols are the same return true; } public override int GetHashCode() { int h = 31 * Length; for (int i = 0; i < Length; i++) { h += 31 * (byte)this[i]; } return h; } } }