Struct Builder

Source
pub struct Builder { /* private fields */ }
Expand description

options in precedence order:

As of 0.2.0: Specify the number symbols excluding the EOF symbol. If you specify an EOF it will automatically increase symbol count by one for the EOF. (or else choose value in range). See the setter for EOF for more detail.

  • counts
    • eof?
  • pdf
    • eof?
    • scale?
  • symbol count
  • symbol count
    • eof?
  • binary - default but can also be explicit

You should only use one of the build paths

Implementations§

Source§

impl Builder

Source

pub fn new() -> Self

Source

pub fn num_symbols(&mut self, count: u32) -> &mut Self

Source

pub fn num_bits(&mut self, size: u32) -> &mut Self

Source

pub fn counts(&mut self, counts: Vec<u32>) -> &mut Self

Constructs new model if you already have counts present. Implied number of symbols from length of counts.

Source

pub fn eof(&mut self, eof: EOFKind) -> &mut Self

  • Specify(u32): Choose a valid index as the EOF [0, counts.len())
  • Start: index 0
  • End: index counts.len() - 1
  • EndAddOne: adds an element to counts and sets EOF to counts.len() - 1
  • None: Same as not specifying. Sets to value outside symbol rangec
Source

pub fn scale(&mut self, scale: u32) -> &mut Self

value = (p * scale)

Therefore besides determining the accuracy, scale is used to determine the elasticity of the model.

Source

pub fn pdf(&mut self, pdf: Vec<f32>) -> &mut Self

constructs a new source_model given a vector of probabilities where the length is the number of symbols (min 10). Defaults scale to length of pdf.

Open to suggestions for default scale This method will not panic on negative values or values greater than 1.0. They dont cause mathematical errors so its on the user to use probabilities correctly.

Source

pub fn binary(&mut self) -> &mut Self

Constructs new model for encoding 0’s and 1’s

Source

pub fn build(&self) -> Model

Trait Implementations§

Source§

impl Default for Builder

Source§

fn default() -> Builder

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.