ECF 1.5
Min.h
1#ifndef Min_h
2#define Min_h
3#include "Primitive.h"
4
5#include <algorithm>
6
7namespace Tree {
8namespace Primitives {
9
14template <class T>
15class MinT : public Primitive
16{
17public:
18 MinT();
19 void execute(void* result, Tree& tree);
20 ~MinT();
21};
22typedef MinT<double> Min;
23
24
25template <class T>
27{
28 nArguments_ = 2;
29 name_ = "min";
30 complementName_ = "max";
31}
32
33
34template <class T>
35MinT<T>::~MinT()
36{ }
37
38
39template <class T>
40void MinT<T>::execute(void* result, Tree& tree)
41{
42 T first, second;
43 T& min = *(T*)result;
44 getNextArgument(&first, tree);
45 getNextArgument(&second, tree);
46 min = std::min(first, second);
47}
48
49}
50}
51
52#endif
Min function primitive (Tree genotype)
Definition: Min.h:16
void execute(void *result, Tree &tree)
Execute the primitive.
Definition: Min.h:40
Base primitive class (Tree genotype).
Definition: Primitive.h:37
Tree class - implements genotype as a tree.
Definition: Tree_c.h:29