Last change
on this file since 14392 was
14392,
checked in by pkimmesw, 8 years ago
|
#2665 Full Push 3.0 instruction set and tests; Added first benchmark test (count odds) for random walk tests;
|
File size:
1.1 KB
|
Line | |
---|
1 | using System;
|
---|
2 | using HeuristicLab.Algorithms.PushGP.Stack;
|
---|
3 |
|
---|
4 | namespace HeuristicLab.Algorithms.PushGP.Expressions
|
---|
5 | {
|
---|
6 | public abstract class PushResultExpression<T> : Expression
|
---|
7 | {
|
---|
8 | public PushResultExpression(string stringRepresentation) : base(stringRepresentation)
|
---|
9 | { }
|
---|
10 |
|
---|
11 | protected void Eval(IStack<T> stack, int count, Func<T[], T> templateFunc)
|
---|
12 | {
|
---|
13 | if (stack.Count < count)
|
---|
14 | return;
|
---|
15 |
|
---|
16 | stack.PushResult(count, templateFunc);
|
---|
17 | }
|
---|
18 |
|
---|
19 | protected void Eval(IStack<T> stack, int count, Func<T[], T> templateFunc, T ignoreValue)
|
---|
20 | {
|
---|
21 | if (stack.Count < count || stack.Top.Equals(ignoreValue))
|
---|
22 | return;
|
---|
23 |
|
---|
24 | stack.PushResult(count, templateFunc);
|
---|
25 | }
|
---|
26 |
|
---|
27 | protected void Eval<R>(IStack<T> stack, IStack<R> resultStack, int count, Func<T[], R> templateFunc)
|
---|
28 | {
|
---|
29 | if (stack.Count < count)
|
---|
30 | return;
|
---|
31 |
|
---|
32 | var items = stack.Pop(count);
|
---|
33 | var result = templateFunc(items);
|
---|
34 |
|
---|
35 | resultStack.Push(result);
|
---|
36 | }
|
---|
37 | }
|
---|
38 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.