Trait GroupTrait

Source
pub trait GroupTrait<T, const N: usize, const R: usize> {
    type Err: Debug;

    // Required methods
    fn new(data: [T; N]) -> Self;
    fn one_cycle(&mut self) -> Result<(), Self::Err>;
    fn iter<'a>(&'a self) -> impl Iterator<Item = &'a Individual<T>>
       where T: 'a;

    // Provided methods
    fn init<I>() -> Self
       where I: InitializerTrait<T, N>,
             Self: Sized { ... }
    fn reset_id(&self) { ... }
    fn one_cycle_out<W>(&mut self, out: &mut W) -> Result<(), Self::Err>
       where W: Write { ... }
    fn clone_values(&self) -> Vec<T>
       where T: Clone { ... }
}
Expand description

A trait for a group which contains individuals.

  • T - A element of this group
  • N - The number of individuals
  • R - The number of individuals after individuals are reduced by selector

Required Associated Types§

Source

type Err: Debug

An error of cycle

Required Methods§

Source

fn new(data: [T; N]) -> Self

Create Self from a array.

  • data - A array of individuals
Source

fn one_cycle(&mut self) -> Result<(), Self::Err>

Run one cycle and update individuals.

Source

fn iter<'a>(&'a self) -> impl Iterator<Item = &'a Individual<T>>
where T: 'a,

Create an iterator of indivuduals.

  • 'a - A lifetime of self.

Provided Methods§

Source

fn init<I>() -> Self
where I: InitializerTrait<T, N>, Self: Sized,

Initialize Self by I algorithm.

  • I - Algorithm of initializing.
Source

fn reset_id(&self)

Assign a number to individuals in order.

Source

fn one_cycle_out<W>(&mut self, out: &mut W) -> Result<(), Self::Err>
where W: Write,

Run one cycle with outputing and update individuals.

By default, there is not outputing.(Run one_cycle simply.)

  • out - A target of outputing.
Source

fn clone_values(&self) -> Vec<T>
where T: Clone,

Clone individuals which are contained by this.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§