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