Functional¶
Flex Functions¶
Warning
doxygenfile: Cannot find file “tools/flex_function.hpp
Function Sets¶
Setup a collection of functions, all with the same signature, that can be run as a group.
- Note
This file is part of Empirical, https://github.com/devosoft/Empirical
- Copyright
Copyright (C) Michigan State University, MIT Software license; see doc/LICENSE.md
- Date
2016-2017
- Note
Status: BETA
-
namespace
emp
If we are in emscripten, make sure to include the header.
-
template<typename
T
>
classFunctionSet
-
template<typename
RETURN_T
, typename ...ARGS
>
classFunctionSet
<RETURN_T(ARGS...)> : public emp::vector<std::function<RETURN_T(ARGS...)>> - #include <FunctionSet.hpp>
A vector of functions that can all be triggered at onece; results can either be returned in a vector or post-processed in a function (such as max, min, etc.) Derived from emp::vector, hence with all of the same methods as vector.
Public Functions
-
FunctionSet
()
-
~FunctionSet
()
-
size_t
GetSize
() const How many functions are in this FunctionSet?
-
void
Add
(const value_type &in_fun) Add a new funtion to this FunctionSet.
-
void
Remove
(size_t pos) Remove the function at a specified position.
-
const emp::vector<RETURN_T> &
Run
(ARGS... args) const Run all functions and return a vector of all results.
-
RETURN_T
Run
(ARGS... args, std::function<RETURN_T(RETURN_T, RETURN_T)> comp_fun, RETURN_T default_val = 0, ) const If you want to provide a filter function, you can retrieve a specific return value. The filter should take in two return values and indicate which is “better”.
-
RETURN_T
FindMax
(ARGS... args, RETURN_T default_val = 0) const Run all functions and return the highest value.
-
RETURN_T
FindMin
(ARGS... args, RETURN_T default_val = 0) const Run all functions and return the lowest value.
-
-
template<typename ...
ARGS
>
classFunctionSet
<void(ARGS...)> : public emp::vector<std::function<void(ARGS...)>> - #include <FunctionSet.hpp>
A specialized version of FunctionSet for void functions.
Public Functions
-
FunctionSet
()
-
~FunctionSet
()
-
size_t
GetSize
() const How many functions are in this FunctionSet?
-
void
Add
(const std::function<void(ARGS...)> &in_fun) Add a new function to this FunctionSet.
-
void
Remove
(size_t pos) Remove the function at the designated position from this FunctionSet.
-
void
Run
(ARGS... args) const Run all functions in the FunctionSet.
-
-
template<typename
Generic Functions¶
Warning
doxygenfile: Cannot find file “emp/functional/GenericFunctions.hpp
Memoized Functions¶
Warning
doxygenfile: Cannot find file “emp/functional/memo_functions.hpp