Trait rustfst::fst_traits::AllocableFst
source · pub trait AllocableFst<W: Semiring>: Fst<W> {
// Required methods
fn reserve_trs(&mut self, source: StateId, additional: usize) -> Result<()>;
unsafe fn reserve_trs_unchecked(
&mut self,
state: StateId,
additional: usize
);
fn reserve_states(&mut self, additional: usize);
fn shrink_to_fit(&mut self);
fn shrink_to_fit_states(&mut self);
fn shrink_to_fit_trs(&mut self, source: StateId) -> Result<()>;
unsafe fn shrink_to_fit_trs_unchecked(&mut self, state: StateId);
fn states_capacity(&self) -> usize;
fn trs_capacity(&self, source: StateId) -> Result<usize>;
unsafe fn trs_capacity_unchecked(&self, state: StateId) -> usize;
}
Expand description
Trait defining the methods to control allocation for a wFST
Required Methods§
sourcefn reserve_trs(&mut self, source: StateId, additional: usize) -> Result<()>
fn reserve_trs(&mut self, source: StateId, additional: usize) -> Result<()>
Reserve capacity for at least additional more trs leaving the state.
The FST may reserve more space to avoid frequent allocation.
After calling reserve_trs
, the capacity will be greater or equal to num_trs
+ additionnal
This method has no effects if the capacity is already sufficient
sourceunsafe fn reserve_trs_unchecked(&mut self, state: StateId, additional: usize)
unsafe fn reserve_trs_unchecked(&mut self, state: StateId, additional: usize)
§Safety
Unsafe behaviour if state
is not present in Fst.
sourcefn reserve_states(&mut self, additional: usize)
fn reserve_states(&mut self, additional: usize)
Reserve capacity for at least additional states.
The FST may reserve more space to avoid frequent allocation.
After calling reserve_states
, the capacity will be greater or equal to num_states
+ additionnal
This method has no effects if the capacity is already sufficient
sourcefn shrink_to_fit(&mut self)
fn shrink_to_fit(&mut self)
Shrinks the capacity of the states and their leaving trs as much as possible. It will drop down as close as possible to the number of states and leaving trs.
sourcefn shrink_to_fit_states(&mut self)
fn shrink_to_fit_states(&mut self)
Shrinks the capacity of the states. It will drop down as close as possible to the number of states.
sourcefn shrink_to_fit_trs(&mut self, source: StateId) -> Result<()>
fn shrink_to_fit_trs(&mut self, source: StateId) -> Result<()>
Shrinks the capacity of the leaving trs for the given state as much as possible. It will drop down as close as possible to theleaving trs.
sourceunsafe fn shrink_to_fit_trs_unchecked(&mut self, state: StateId)
unsafe fn shrink_to_fit_trs_unchecked(&mut self, state: StateId)
Shrinks the capacity of the leaving trs for the given state as much as possible. It will drop down as close as possible to theleaving trs.
§Safety
Unsafe behaviour if state
is not present in Fst.
sourcefn states_capacity(&self) -> usize
fn states_capacity(&self) -> usize
Returns the number of states the FST can hold without reallocating.
sourcefn trs_capacity(&self, source: StateId) -> Result<usize>
fn trs_capacity(&self, source: StateId) -> Result<usize>
Returns the number of trs for a given state the FST can hold without reallocating.
sourceunsafe fn trs_capacity_unchecked(&self, state: StateId) -> usize
unsafe fn trs_capacity_unchecked(&self, state: StateId) -> usize
Returns the number of trs for a given state the FST can hold without reallocating.
§Safety
Unsafe behaviour if state
is not present in Fst.