Last change
on this file since 14834 was
14834,
checked in by pkimmesw, 7 years ago
|
#2665 LexicaseSelector, Performance improvements, UI Fixes, Debugger only shows used stacks, fixed Debugger stepping, Added vector expressions, ERCOptions,
|
File size:
1004 bytes
|
Line | |
---|
1 | namespace 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 bool Eval(IPushStack<T> stack, int count, Func<T[], T> templateFunc) {
|
---|
8 | if (stack.Count < count) return false;
|
---|
9 |
|
---|
10 | stack.PushResult(count, templateFunc);
|
---|
11 | return true;
|
---|
12 | }
|
---|
13 |
|
---|
14 | protected bool Eval(IPushStack<T> stack, int count, Func<T[], T> templateFunc, T ignoreValue) {
|
---|
15 | if ((stack.Count < count) || stack.Top.Equals(ignoreValue)) return false;
|
---|
16 |
|
---|
17 | stack.PushResult(count, templateFunc);
|
---|
18 | return true;
|
---|
19 | }
|
---|
20 |
|
---|
21 | protected bool Eval<R>(IPushStack<T> stack, IPushStack<R> resultStack, int count, Func<T[], R> templateFunc) {
|
---|
22 | if (stack.Count < count) return false;
|
---|
23 |
|
---|
24 | var items = stack.Pop(count);
|
---|
25 | var result = templateFunc(items);
|
---|
26 |
|
---|
27 | resultStack.Push(result);
|
---|
28 | return true;
|
---|
29 | }
|
---|
30 | }
|
---|
31 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.