Free cookie consent management tool by TermsFeed Policy Generator

source: branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/PushResultExpression.cs @ 14727

Last change on this file since 14727 was 14727, checked in by pkimmesw, 7 years ago

#2665 PushGP HL Integration, Views, Parameters

File size: 910 bytes
Line 
1namespace HeuristicLab.Problems.ProgramSynthesis.Push.Expressions {
2  using System;
3
4  using HeuristicLab.Problems.ProgramSynthesis.Push.Stack;
5
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;
9
10      stack.PushResult(count, templateFunc);
11    }
12
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;
15
16      stack.PushResult(count, templateFunc);
17    }
18
19    protected void Eval<R>(IStack<T> stack, IStack<R> resultStack, int count, Func<T[], R> templateFunc) {
20      if (stack.Count < count) return;
21
22      var items = stack.Pop(count);
23      var result = templateFunc(items);
24
25      resultStack.Push(result);
26    }
27  }
28}
Note: See TracBrowser for help on using the repository browser.