Changeset 15017 for branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/VectorSetExpressions.cs
- Timestamp:
- 06/01/17 09:28:34 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/VectorSetExpressions.cs
r14952 r15017 4 4 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 5 5 using HeuristicLab.Problems.ProgramSynthesis.Push.Attributes; 6 using HeuristicLab.Problems.ProgramSynthesis.Push.Extensions; 6 7 using HeuristicLab.Problems.ProgramSynthesis.Push.Interpreter; 7 8 using HeuristicLab.Problems.ProgramSynthesis.Push.Stack; … … 17 18 protected VectorSetExpression(bool deserializing) : base(deserializing) { } 18 19 19 protected bool IsNoop(IInternalPushInterpreter interpreter, IPushStack< List<T>> vectorStack, IPushStack<T> literalStack, bool isLiteralTypeInteger = false) {20 protected bool IsNoop(IInternalPushInterpreter interpreter, IPushStack<IReadOnlyList<T>> vectorStack, IPushStack<T> literalStack, bool isLiteralTypeInteger = false) { 20 21 return vectorStack.IsEmpty || 21 22 vectorStack.Top.Count == 0 || … … 27 28 protected void Eval( 28 29 IInternalPushInterpreter interpreter, 29 IPushStack< List<T>> vectorStack,30 IPushStack<IReadOnlyList<T>> vectorStack, 30 31 IPushStack<T> literalStack, 31 32 bool isLiteralTypeInteger = false) { 32 33 T literal; 33 int index;34 long x; 34 35 35 36 if (isLiteralTypeInteger) { 36 37 literal = literalStack.Top; 37 index = (int)interpreter.IntegerStack[1];38 x = interpreter.IntegerStack[1]; 38 39 interpreter.IntegerStack.Remove(2); 39 40 } else { 40 41 literal = literalStack.Pop(); 41 index = (int)interpreter.IntegerStack.Pop();42 x = interpreter.IntegerStack.Pop(); 42 43 } 43 44 44 var vector = vectorStack.Pop(); 45 index = index % vector.Count; 45 var vector = vectorStack.Top; 46 var newTop = new List<T>(vector); 47 var index = x.AsInt(vector.Count); 46 48 47 49 if (index < 0) 48 50 index *= -1; 49 51 50 vector[index] = literal; 52 newTop[index] = literal; 53 vectorStack.Top = newTop; 51 54 } 52 55 }
Note: See TracChangeset
for help on using the changeset viewer.