Changeset 16026 for branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/GrammarEnumeration/Symbol.cs
- Timestamp:
- 07/27/18 19:28:18 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/GrammarEnumeration/Symbol.cs
r16019 r16026 2 2 using System.Collections; 3 3 using System.Collections.Generic; 4 using System.Diagnostics; 4 5 using System.Linq; 5 6 using HeuristicLab.Common; … … 102 103 } 103 104 104 [StorableClass] 105 public class Production : DeepCloneable, IList<Symbol> { 106 [Storable] 107 private List<Symbol> symbols; 108 109 public int Count { get { return symbols.Count; } } 110 111 public bool IsReadOnly { 112 get { return false; } 113 } 114 115 public Symbol this[int index] { 116 get { return symbols[index]; } 117 set { symbols[index] = value; } 118 } 119 120 public Production(params Symbol[] symbols) { 121 this.symbols = symbols.ToList(); 122 } 123 124 public Production(IEnumerable<Symbol> symbols) { 125 this.symbols = symbols.ToList(); 126 } 127 128 [StorableConstructor] 129 protected Production(bool deserializing) { } 130 131 protected Production(Production original, Cloner cloner) { 132 symbols = original.symbols.Select(cloner.Clone).ToList(); 133 } 134 135 public override IDeepCloneable Clone(Cloner cloner) { 136 return new Production(this, cloner); 137 } 138 139 public override string ToString() { 140 return string.Join(" ", this); 141 } 142 143 #region IList<Symbol> methods 144 public IEnumerator<Symbol> GetEnumerator() { 145 return symbols.GetEnumerator(); 146 } 147 148 IEnumerator IEnumerable.GetEnumerator() { 149 return GetEnumerator(); 150 } 151 152 public int IndexOf(Symbol item) { 153 return symbols.IndexOf(item); 154 } 155 156 public void Insert(int index, Symbol item) { 157 symbols.Insert(index, item); 158 } 159 160 public void RemoveAt(int index) { 161 symbols.RemoveAt(index); 162 } 163 164 public void Add(Symbol item) { 165 symbols.Add(item); 166 } 167 168 public void Clear() { 169 symbols.Clear(); 170 } 171 172 public bool Contains(Symbol item) { 173 return symbols.Contains(item); 174 } 175 176 public void CopyTo(Symbol[] array, int arrayIndex) { 177 symbols.CopyTo(array, arrayIndex); 178 } 179 180 public void CopyTo(int index, Symbol[] array, int arrayIndex, int count) { 181 symbols.CopyTo(index, array, arrayIndex, count); 182 } 183 184 public bool Remove(Symbol item) { 185 return symbols.Remove(item); 186 } 187 #endregion 188 } 105 189 106 }
Note: See TracChangeset
for help on using the changeset viewer.