Changeset 14513 for branches/PushGP/HeuristicLab.Algorithms.PushGP/HeuristicLab.Algorithms.PushGP/Expressions/RotateExpressions.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/RotateExpressions.cs
r14398 r14513 1 using HeuristicLab.Algorithms.PushGP.Interpreter; 2 using HeuristicLab.Algorithms.PushGP.Stack; 1 namespace HeuristicLab.Algorithms.PushGP.Expressions 2 { 3 using HeuristicLab.Algorithms.PushGP.Interpreter; 4 using HeuristicLab.Algorithms.PushGP.Stack; 3 5 4 namespace HeuristicLab.Algorithms.PushGP.Expressions 5 {6 public abstract class RotateExpression<T> : StatelessExpression6 public abstract class RotateExpression<T> : StatelessExpression 7 { 8 public void Eval(IStack<T> stack) 7 9 { 8 public void Eval(IStack<T> stack) 9 { 10 if (stack.Count < 3) 11 return; 10 if (stack.Count < 3) return; 12 11 13 stack.Swap(3); 14 } 12 stack.Swap(3); 13 } 14 } 15 16 public class IntegerRotateExpression : RotateExpression<long> 17 { 18 protected override string InitStringRepresentation() 19 { 20 return "INTEGER.ROT"; 15 21 } 16 22 17 public class IntegerRotateExpression : RotateExpression<long>23 public override void Eval(IPushGpInterpreter interpreter) 18 24 { 19 protected override string InitStringRepresentation() { return "INTEGER.ROT"; } 25 this.Eval(interpreter.IntegerStack); 26 } 27 } 20 28 21 public override void Eval(IInterpreter interpreter) 22 { 23 Eval(interpreter.IntegerStack); 24 } 29 public class FloatRotateExpression : RotateExpression<double> 30 { 31 protected override string InitStringRepresentation() 32 { 33 return "FLOAT.ROT"; 25 34 } 26 35 27 public class FloatRotateExpression : RotateExpression<double>36 public override void Eval(IPushGpInterpreter interpreter) 28 37 { 29 protected override string InitStringRepresentation() { return "FLOAT.ROT"; } 38 this.Eval(interpreter.FloatStack); 39 } 40 } 30 41 31 public override void Eval(IInterpreter interpreter) 32 { 33 Eval(interpreter.FloatStack); 34 } 42 public class BooleanRotateExpression : RotateExpression<bool> 43 { 44 protected override string InitStringRepresentation() 45 { 46 return "BOOLEAN.ROT"; 35 47 } 36 48 37 public class BooleanRotateExpression : RotateExpression<bool>49 public override void Eval(IPushGpInterpreter interpreter) 38 50 { 39 protected override string InitStringRepresentation() { return "BOOLEAN.ROT"; } 51 this.Eval(interpreter.BooleanStack); 52 } 53 } 40 54 41 public override void Eval(IInterpreter interpreter) 42 { 43 Eval(interpreter.BooleanStack); 44 } 55 public class NameRotateExpression : RotateExpression<string> 56 { 57 protected override string InitStringRepresentation() 58 { 59 return "NAME.ROT"; 45 60 } 46 61 47 public class NameRotateExpression : RotateExpression<string>62 public override void Eval(IPushGpInterpreter interpreter) 48 63 { 49 protected override string InitStringRepresentation() { return "NAME.ROT"; } 64 this.Eval(interpreter.NameStack); 65 } 66 } 50 67 51 public override void Eval(IInterpreter interpreter) 52 { 53 Eval(interpreter.NameStack); 54 } 68 public class ExecRotateExpression : RotateExpression<Expression> 69 { 70 protected override string InitStringRepresentation() 71 { 72 return "EXEC.ROT"; 55 73 } 56 74 57 public class ExecRotateExpression : RotateExpression<Expression>75 public override void Eval(IPushGpInterpreter interpreter) 58 76 { 59 protected override string InitStringRepresentation() { return "EXEC.ROT"; } 77 this.Eval(interpreter.ExecStack); 78 } 79 } 60 80 61 public override void Eval(IInterpreter interpreter) 62 { 63 Eval(interpreter.ExecStack); 64 } 81 public class CodeRotateExpression : RotateExpression<Expression> 82 { 83 protected override string InitStringRepresentation() 84 { 85 return "CODE.ROT"; 65 86 } 66 87 67 public class CodeRotateExpression : RotateExpression<Expression>88 public override void Eval(IPushGpInterpreter interpreter) 68 89 { 69 protected override string InitStringRepresentation() { return "CODE.ROT"; } 70 71 public override void Eval(IInterpreter interpreter) 72 { 73 Eval(interpreter.CodeStack); 74 } 90 this.Eval(interpreter.CodeStack); 75 91 } 92 } 76 93 }
Note: See TracChangeset
for help on using the changeset viewer.