pub struct ExprArena { /* private fields */ }Implementations§
Source§impl ExprArena
impl ExprArena
pub fn new() -> Self
pub fn with_capacity(cap: usize) -> Self
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn push(&mut self, node: ExprNode) -> ExprId
pub fn push(&mut self, node: ExprNode) -> ExprId
§Panics
Panics if the number of expressions exceeds u32::MAX (expression arena overflow).
pub fn get(&self, id: ExprId) -> &ExprNode
pub fn get_mut(&mut self, id: ExprId) -> &mut ExprNode
pub fn nodes(&self) -> &[ExprNode]
pub fn constant(&mut self, v: f64) -> ExprId
pub fn var(&mut self, v: VarId) -> ExprId
pub fn param(&mut self, p: ParamId) -> ExprId
Sourcepub fn new_param(&mut self, value: f64) -> ParamId
pub fn new_param(&mut self, value: f64) -> ParamId
Allocate a fresh parameter initialized to value, returning its
ParamId. Push a ExprNode::Param with Self::param to reference
it inside an expression.
§Panics
Panics if the number of parameters exceeds u32::MAX.
pub fn num_params(&self) -> usize
Sourcepub fn param_value(&self, p: ParamId) -> f64
pub fn param_value(&self, p: ParamId) -> f64
Current value bound to parameter p.
§Panics
Panics if p was not allocated by Self::new_param on this arena.
Sourcepub fn try_param_value(&self, p: ParamId) -> Option<f64>
pub fn try_param_value(&self, p: ParamId) -> Option<f64>
Look up the value of p, returning None if p is out of range.
Sourcepub fn set_param_value(&mut self, p: ParamId, value: f64)
pub fn set_param_value(&mut self, p: ParamId, value: f64)
Re-bind parameter p to value. Takes effect on the next extraction or
evaluation.
§Panics
Panics if p was not allocated by Self::new_param on this arena.
pub fn linear(&mut self, coeffs: Vec<(VarId, f64)>, constant: f64) -> ExprId
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ExprArena
impl RefUnwindSafe for ExprArena
impl Send for ExprArena
impl Sync for ExprArena
impl Unpin for ExprArena
impl UnsafeUnpin for ExprArena
impl UnwindSafe for ExprArena
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more