Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::CA::Outer_Totalistic_Rule< F > Class Template Reference

Rule whose next state depends on (current, alive_count). More...

#include <tpl_ca_rule.H>

Public Member Functions

constexpr Outer_Totalistic_Rule (F func)
 Construct an outer-totalistic rule from a functor.
 
template<typename State >
constexpr State operator() (const State &current, Neighbor_View< State > neighbours) const
 Compute the next state from current value and neighbours.
 

Private Attributes

F f_
 

Detailed Description

template<typename F>
class Aleph::CA::Outer_Totalistic_Rule< F >

Rule whose next state depends on (current, alive_count).

"Alive" is defined as any non-zero neighbour value (so this rule works equally well for bool and small integral state types). The wrapped functor F receives the current state and the number of non-zero neighbours, and returns the next state.

Template Parameters
Ffunctor type with signature (State, std::size_t) -> State.

Definition at line 98 of file tpl_ca_rule.H.

Constructor & Destructor Documentation

◆ Outer_Totalistic_Rule()

template<typename F >
constexpr Aleph::CA::Outer_Totalistic_Rule< F >::Outer_Totalistic_Rule ( F  func)
inlineexplicitconstexpr

Construct an outer-totalistic rule from a functor.

Parameters
[in]funccallable object receiving (State current, std::size_t alive).
Exceptions
Anyexception thrown while moving/copying func.

Definition at line 109 of file tpl_ca_rule.H.

Member Function Documentation

◆ operator()()

template<typename F >
template<typename State >
constexpr State Aleph::CA::Outer_Totalistic_Rule< F >::operator() ( const State &  current,
Neighbor_View< State >  neighbours 
) const
inlineconstexpr

Compute the next state from current value and neighbours.

Template Parameters
Statecell state type.
Parameters
[in]currentcurrent centre-cell state.
[in]neighboursread-only neighbour values.
Returns
next state produced by the wrapped functor.
Exceptions
Anyexception thrown by the wrapped functor.

Definition at line 120 of file tpl_ca_rule.H.

References Aleph::CA::Outer_Totalistic_Rule< F >::f_.

Member Data Documentation

◆ f_

template<typename F >
F Aleph::CA::Outer_Totalistic_Rule< F >::f_
private

Definition at line 100 of file tpl_ca_rule.H.

Referenced by Aleph::CA::Outer_Totalistic_Rule< F >::operator()().


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