Struct ketree::tree::Tree
[−]
pub struct Tree<T: 'static + Clone + Debug> { /* fields omitted */ }
A Tree that represents a symbolic expression that can be constructed with Ketos.
Methods
impl<T: 'static + Clone + Debug> Tree<T>
[src]
fn new(ex: Expression<T>) -> Tree<T>
Constructor to create a Tree vertex with data.
fn reduce(&mut self)
Reduces the complexity of the tree using recursion by evaluating operators with branches that are constants.
This method is limited by the depth of the machine's recursive stack.
fn accumulate(&self, vars: &HashMap<String, T>) -> Result<T, TreeError>
Evaluates the tree with the provided map of variables.
'vars' should be any HashMap that maps Variables in the tree to values.
fn accumulate_recurse(&self, vars: &HashMap<String, T>) -> Result<T, TreeError>
Evaluates the tree using recursion with the provided map of variables.
'vars' should be any HashMap that maps Variables in the tree to values.
This method is limited by the depth of the machine's recursive stack.
fn link(&mut self, b: Vec<Tree<T>>)
Links the provided Vector of Trees as branches to self.
fn data(&self) -> &Expression<T>
Returns a reference to contained data.
fn children(&self) -> &Option<Vec<Tree<T>>>
Returns a reference to contained children.
fn post_iter(&self) -> TreePostIter<T>
Returns a TreePostIter for the tree.
Trait Implementations
impl<T: Clone + 'static + Clone + Debug> Clone for Tree<T>
[src]
fn clone(&self) -> Tree<T>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<T: Debug + 'static + Clone + Debug> Debug for Tree<T>
[src]
impl<T: 'static + Clone + Debug> ForeignValue for Tree<T>
fn type_name(&self) -> &'static str
Return the value's type name.
fn compare_to(
&self,
rhs: &(ForeignValue + 'static)
) -> Result<Ordering, ExecError>
&self,
rhs: &(ForeignValue + 'static)
) -> Result<Ordering, ExecError>
Performs ordered comparison between two values of a foreign type. Read more
fn compare_to_value(&self, rhs: &Value) -> Result<Ordering, ExecError>
Performs ordered comparison between two values. Read more
fn is_identical_to(&self, rhs: &(ForeignValue + 'static)) -> bool
Returns whether the two values are identical. This concept is the same as equality, except in the case of floating point values, where two NaN
values are considered identical. Read more
fn is_equal_to(&self, rhs: &(ForeignValue + 'static)) -> Result<bool, ExecError>
Tests for equality between two values of a foreign type. Read more
fn is_equal_to_value(&self, rhs: &Value) -> Result<bool, ExecError>
Tests for equality between two values. Read more
fn fmt_debug(&self, names: &NameStore, f: &mut Formatter) -> Result<(), Error>
Format the value in debugging mode. Read more
fn fmt_display(&self, names: &NameStore, f: &mut Formatter) -> Result<(), Error>
Format the value in display mode. Read more
fn is_type(&self, name: &str) -> bool
Returns whether this value is of the named type. Read more
fn call_value(&self, ctx: &Context, args: &mut [Value]) -> Result<Value, Error>
Calls the value as a function. Read more
fn size(&self) -> usize
Returns an estimate of the memory held by this value. Read more
impl<T: 'static + Clone + Debug> FromValue for Tree<T>
fn from_value(v: Value) -> Result<Self, ExecError>
Consumes the Value
and returns a Rust value
impl<'value, T: 'static + Clone + Debug> FromValueRef<'value> for &'value Tree<T>
fn from_value_ref(v: &'value Value) -> Result<Self, ExecError>
Returns the borrowed value
impl<T: 'static + Clone + Debug> StructValue for Tree<T>
fn struct_name() -> &'static str
Returns the struct
name.
fn from_fields(
scope: &Scope,
def: &Rc<StructDef>,
fields: &mut [(Name, Value)]
) -> Result<Self, Error>
scope: &Scope,
def: &Rc<StructDef>,
fields: &mut [(Name, Value)]
) -> Result<Self, Error>
Creates a value from a list of fields. Read more
fn field_names() -> &'static [&'static str]
Returns a list of field names.
fn get_field(
&self,
scope: &Scope,
def: &Rc<StructDef>,
name: Name
) -> Result<Value, Error>
&self,
scope: &Scope,
def: &Rc<StructDef>,
name: Name
) -> Result<Value, Error>
Returns a copy of a field as a Ketos Value
. Read more
fn replace_fields(
&mut self,
scope: &Scope,
def: &Rc<StructDef>,
fields: &mut [(Name, Value)]
) -> Result<(), Error>
&mut self,
scope: &Scope,
def: &Rc<StructDef>,
fields: &mut [(Name, Value)]
) -> Result<(), Error>
Modifies the value to replace named fields with provided values. Read more