Empirical
Public Types | Public Member Functions | Public Attributes | Protected Attributes | List of all members
emp::FunctionSet< RETURN_T(ARGS...)> Class Template Reference

#include <FunctionSet.h>

Inheritance diagram for emp::FunctionSet< RETURN_T(ARGS...)>:
emp::vector< std::function< RETURN_T(ARGS...)> >

Public Types

using base_t = emp::vector< std::function< RETURN_T(ARGS...)>>
 
using value_type = typename base_t::value_type
 
using return_t = RETURN_T
 
using iterator = iterator_wrapper< typename stdv_t::iterator >
 
using const_iterator = iterator_wrapper< typename stdv_t::const_iterator >
 
using reverse_iterator = iterator_wrapper< typename stdv_t::reverse_iterator >
 
using const_reverse_iterator = iterator_wrapper< typename stdv_t::const_reverse_iterator >
 
using size_type = typename stdv_t::size_type
 
using reference = typename stdv_t::reference
 
using const_reference = typename stdv_t::const_reference
 

Public Member Functions

 FunctionSet ()
 
 ~FunctionSet ()
 
size_t GetSize () const
 How many functions are in this FunctionSet? More...
 
void Add (const value_type &in_fun)
 Add a new funtion to this FunctionSet. More...
 
void Remove (size_t pos)
 Remove the function at a specified position. More...
 
const emp::vector< RETURN_T > & Run (ARGS...args) const
 Run all functions and return a vector of all results. More...
 
RETURN_T Run (ARGS...args, std::function< RETURN_T(RETURN_T, RETURN_T)> comp_fun, RETURN_T default_val=0) const
 
RETURN_T FindMax (ARGS...args, RETURN_T default_val=0) const
 Run all functions and return the highest value. More...
 
RETURN_T FindMin (ARGS...args, RETURN_T default_val=0) const
 Run all functions and return the lowest value. More...
 
RETURN_T FindSum (ARGS...args, RETURN_T default_val=0) const
 Run all functions and return the total value. More...
 
RETURN_T FindProduct (ARGS...args, RETURN_T default_val=1) const
 Run all functions and return a product of all values. More...
 
size_t size () const
 
iterator begin () noexcept
 
const_iterator begin () const noexcept
 
iterator end () noexcept
 
const_iterator end () const noexcept
 
void resize (size_t new_size)
 
void resize (size_t new_size, const std::function< RETURN_T(ARGS...)> &val)
 
std::function< RETURN_T(ARGS...)> & operator[] (size_t pos)
 
const std::function< RETURN_T(ARGS...)> & operator[] (size_t pos) const
 
std::function< RETURN_T(ARGS...)> & back ()
 
const std::function< RETURN_T(ARGS...)> & back () const
 
std::function< RETURN_T(ARGS...)> & front ()
 
const std::function< RETURN_T(ARGS...)> & front () const
 
void push_back (PB_Ts &&...args)
 
void pop_back ()
 
iterator insert (ARGS &&...args)
 
iterator erase (ARGS &&...args)
 
iterator emplace (ARGS &&...args)
 
void emplace_back (ARGS &&...args)
 

Public Attributes

int revision
 Setup a revision number - iterators must match the revision of their vector. More...
 

Protected Attributes

emp::vector< RETURN_T > return_vals
 

Detailed Description

template<typename RETURN_T, typename... ARGS>
class emp::FunctionSet< RETURN_T(ARGS...)>

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.

Member Typedef Documentation

template<typename RETURN_T , typename... ARGS>
using emp::FunctionSet< RETURN_T(ARGS...)>::base_t = emp::vector<std::function<RETURN_T(ARGS...)>>
using emp::vector< std::function< RETURN_T(ARGS...)> , Ts >::const_iterator = iterator_wrapper< typename stdv_t::const_iterator >
inherited
using emp::vector< std::function< RETURN_T(ARGS...)> , Ts >::const_reference = typename stdv_t::const_reference
inherited
using emp::vector< std::function< RETURN_T(ARGS...)> , Ts >::const_reverse_iterator = iterator_wrapper< typename stdv_t::const_reverse_iterator >
inherited
using emp::vector< std::function< RETURN_T(ARGS...)> , Ts >::iterator = iterator_wrapper< typename stdv_t::iterator >
inherited
using emp::vector< std::function< RETURN_T(ARGS...)> , Ts >::reference = typename stdv_t::reference
inherited
template<typename RETURN_T , typename... ARGS>
using emp::FunctionSet< RETURN_T(ARGS...)>::return_t = RETURN_T
using emp::vector< std::function< RETURN_T(ARGS...)> , Ts >::reverse_iterator = iterator_wrapper< typename stdv_t::reverse_iterator >
inherited
using emp::vector< std::function< RETURN_T(ARGS...)> , Ts >::size_type = typename stdv_t::size_type
inherited
template<typename RETURN_T , typename... ARGS>
using emp::FunctionSet< RETURN_T(ARGS...)>::value_type = typename base_t::value_type

Constructor & Destructor Documentation

template<typename RETURN_T , typename... ARGS>
emp::FunctionSet< RETURN_T(ARGS...)>::FunctionSet ( )
inline
template<typename RETURN_T , typename... ARGS>
emp::FunctionSet< RETURN_T(ARGS...)>::~FunctionSet ( )
inline

Member Function Documentation

template<typename RETURN_T , typename... ARGS>
void emp::FunctionSet< RETURN_T(ARGS...)>::Add ( const value_type in_fun)
inline

Add a new funtion to this FunctionSet.

std::function< RETURN_T(ARGS...)> & emp::vector< std::function< RETURN_T(ARGS...)> , Ts >::back ( )
inlineinherited
const std::function< RETURN_T(ARGS...)> & emp::vector< std::function< RETURN_T(ARGS...)> , Ts >::back ( ) const
inlineinherited
iterator emp::vector< std::function< RETURN_T(ARGS...)> , Ts >::begin ( )
inlinenoexceptinherited
const_iterator emp::vector< std::function< RETURN_T(ARGS...)> , Ts >::begin ( ) const
inlinenoexceptinherited
iterator emp::vector< std::function< RETURN_T(ARGS...)> , Ts >::emplace ( ARGS &&...  args)
inlineinherited
void emp::vector< std::function< RETURN_T(ARGS...)> , Ts >::emplace_back ( ARGS &&...  args)
inlineinherited
iterator emp::vector< std::function< RETURN_T(ARGS...)> , Ts >::end ( )
inlinenoexceptinherited
const_iterator emp::vector< std::function< RETURN_T(ARGS...)> , Ts >::end ( ) const
inlinenoexceptinherited
iterator emp::vector< std::function< RETURN_T(ARGS...)> , Ts >::erase ( ARGS &&...  args)
inlineinherited
template<typename RETURN_T , typename... ARGS>
RETURN_T emp::FunctionSet< RETURN_T(ARGS...)>::FindMax ( ARGS...  args,
RETURN_T  default_val = 0 
) const
inline

Run all functions and return the highest value.

template<typename RETURN_T , typename... ARGS>
RETURN_T emp::FunctionSet< RETURN_T(ARGS...)>::FindMin ( ARGS...  args,
RETURN_T  default_val = 0 
) const
inline

Run all functions and return the lowest value.

template<typename RETURN_T , typename... ARGS>
RETURN_T emp::FunctionSet< RETURN_T(ARGS...)>::FindProduct ( ARGS...  args,
RETURN_T  default_val = 1 
) const
inline

Run all functions and return a product of all values.

template<typename RETURN_T , typename... ARGS>
RETURN_T emp::FunctionSet< RETURN_T(ARGS...)>::FindSum ( ARGS...  args,
RETURN_T  default_val = 0 
) const
inline

Run all functions and return the total value.

std::function< RETURN_T(ARGS...)> & emp::vector< std::function< RETURN_T(ARGS...)> , Ts >::front ( )
inlineinherited
const std::function< RETURN_T(ARGS...)> & emp::vector< std::function< RETURN_T(ARGS...)> , Ts >::front ( ) const
inlineinherited
template<typename RETURN_T , typename... ARGS>
size_t emp::FunctionSet< RETURN_T(ARGS...)>::GetSize ( ) const
inline

How many functions are in this FunctionSet?

iterator emp::vector< std::function< RETURN_T(ARGS...)> , Ts >::insert ( ARGS &&...  args)
inlineinherited
std::function< RETURN_T(ARGS...)> & emp::vector< std::function< RETURN_T(ARGS...)> , Ts >::operator[] ( size_t  pos)
inlineinherited
const std::function< RETURN_T(ARGS...)> & emp::vector< std::function< RETURN_T(ARGS...)> , Ts >::operator[] ( size_t  pos) const
inlineinherited
void emp::vector< std::function< RETURN_T(ARGS...)> , Ts >::pop_back ( )
inlineinherited
void emp::vector< std::function< RETURN_T(ARGS...)> , Ts >::push_back ( PB_Ts &&...  args)
inlineinherited
template<typename RETURN_T , typename... ARGS>
void emp::FunctionSet< RETURN_T(ARGS...)>::Remove ( size_t  pos)
inline

Remove the function at a specified position.

void emp::vector< std::function< RETURN_T(ARGS...)> , Ts >::resize ( size_t  new_size)
inlineinherited
void emp::vector< std::function< RETURN_T(ARGS...)> , Ts >::resize ( size_t  new_size,
const std::function< RETURN_T(ARGS...)> &  val 
)
inlineinherited
template<typename RETURN_T , typename... ARGS>
const emp::vector<RETURN_T>& emp::FunctionSet< RETURN_T(ARGS...)>::Run ( ARGS...  args) const
inline

Run all functions and return a vector of all results.

template<typename RETURN_T , typename... ARGS>
RETURN_T emp::FunctionSet< RETURN_T(ARGS...)>::Run ( ARGS...  args,
std::function< RETURN_T(RETURN_T, RETURN_T)>  comp_fun,
RETURN_T  default_val = 0 
) const
inline

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".

size_t emp::vector< std::function< RETURN_T(ARGS...)> , Ts >::size ( ) const
inlineinherited

Member Data Documentation

template<typename RETURN_T , typename... ARGS>
emp::vector<RETURN_T> emp::FunctionSet< RETURN_T(ARGS...)>::return_vals
mutableprotected
int emp::vector< std::function< RETURN_T(ARGS...)> , Ts >::revision
inherited

Setup a revision number - iterators must match the revision of their vector.


The documentation for this class was generated from the following file: