Skip to main content

Sampler

Trait Sampler 

Source
pub trait Sampler {
    type Iter: Iterator<Item = usize>;

    // Required methods
    fn iter(&self) -> Self::Iter;
    fn epoch(&self) -> u64;
    fn set_epoch(&mut self, epoch: u64);

    // Provided method
    fn exact_len(&self) -> Option<usize> { ... }
}
Expand description

A reusable, epoch-aware source of finite sample indices.

Every call to Sampler::iter creates a fresh iterator. An exact length is optional and is never required for iteration.

Required Associated Types§

Source

type Iter: Iterator<Item = usize>

A fresh finite iterator over sample indices.

Required Methods§

Source

fn iter(&self) -> Self::Iter

Creates an iterator for the current epoch.

Source

fn epoch(&self) -> u64

Returns the current epoch.

Source

fn set_epoch(&mut self, epoch: u64)

Selects the epoch used by future iterators.

Provided Methods§

Source

fn exact_len(&self) -> Option<usize>

Returns the exact number of indices when it is known.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§