[−][src]Trait r_fairdist::counter::Counter
Multi-dimensional resource counter
This trait represents a set of resource counters that can be indexed to access the individual scalar counters. In its simplest form it can be thought of as an array of scalar counters, but more complex setups are possible.
A resource counter needs to select the index used to access the individual slots, the scalar type that each slot uses, as well as a function to replicate itself.
Associated Types
Loading content...Required methods
fn from_template(template: &Self) -> Self
Create new counter from a template.
This takes an existing counter as a template and creates a new counter that has the same dimensions. The new counter is initialized to zero. That is, the template is only used to make sure both counters have the same amount of slots.
fn slot(&mut self, index: &Self::Index) -> &mut Self::Scalar
Dereference an individual slot on the counter.
This function returns a mutable reference to the slot with index [index]
. It is similar
to an implementation of [std::ops::IndexMut]
, but takes a reference as index.
fn empty(&self) -> bool
Check whether the counter is empty.
This checks all slots of the counter whether they are empty. If all are empty (that is,
they are 0
, as in num::Zero::is_zero()
), this will return true
, otherwise false
is
returned.
Implementations on Foreign Types
impl<S> Counter for [S; 1] where
S: Scalar,
[src]
S: Scalar,
type Index = ()
type Scalar = S
fn from_template(_template: &Self) -> Self
[src]
fn slot(&mut self, _index: &Self::Index) -> &mut Self::Scalar
[src]
fn empty(&self) -> bool
[src]
impl<S> Counter for Box<[S]> where
S: Scalar,
[src]
S: Scalar,