Changeset 14513 for branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/PushResultExpression.cs
- Timestamp:
- 12/20/16 22:57:11 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/PushResultExpression.cs
r14398 r14513 1 using System;2 using HeuristicLab.Algorithms.PushGP.Stack;1 namespace HeuristicLab.Algorithms.PushGP.Expressions { 2 using System; 3 3 4 namespace HeuristicLab.Algorithms.PushGP.Expressions 5 { 6 public abstract class PushResultExpression<T> : StatelessExpression 7 { 8 protected void Eval(IStack<T> stack, int count, Func<T[], T> templateFunc) 9 { 10 if (stack.Count < count) 11 return; 4 using HeuristicLab.Algorithms.PushGP.Stack; 12 5 13 stack.PushResult(count, templateFunc); 14 } 6 public abstract class PushResultExpression<T> : StatelessExpression { 7 protected void Eval(IStack<T> stack, int count, Func<T[], T> templateFunc) { 8 if (stack.Count < count) return; 15 9 16 protected void Eval(IStack<T> stack, int count, Func<T[], T> templateFunc, T ignoreValue) 17 { 18 if (stack.Count < count || stack.Top.Equals(ignoreValue)) 19 return; 10 stack.PushResult(count, templateFunc); 11 } 20 12 21 stack.PushResult(count, templateFunc);22 }13 protected void Eval(IStack<T> stack, int count, Func<T[], T> templateFunc, T ignoreValue) { 14 if ((stack.Count < count) || stack.Top.Equals(ignoreValue)) return; 23 15 24 protected void Eval<R>(IStack<T> stack, IStack<R> resultStack, int count, Func<T[], R> templateFunc) 25 { 26 if (stack.Count < count) 27 return; 16 stack.PushResult(count, templateFunc); 17 } 28 18 29 var items = stack.Pop(count);30 var result = templateFunc(items);19 protected void Eval<R>(IStack<T> stack, IStack<R> resultStack, int count, Func<T[], R> templateFunc) { 20 if (stack.Count < count) return; 31 21 32 resultStack.Push(result); 33 } 22 var items = stack.Pop(count); 23 var result = templateFunc(items); 24 25 resultStack.Push(result); 34 26 } 27 } 35 28 }
Note: See TracChangeset
for help on using the changeset viewer.