![]() |
NDEVR
API Documentation
|
A solvable mathematical formula composed of variables, numbers, and operations. More...
Classes | |
| struct | EquationPart |
| Represents a single element in the equation stack, consisting of an operator and a value. More... | |
Public Member Functions | |
| Equation () | |
| Default constructor. | |
| void | add (char operation, const String &value) |
| Appends a variable-referencing equation part to the equation stack. | |
| void | add (char operation, t_type value) |
| Appends a numeric equation part to the equation stack. | |
| void | addOrderOfOps (char operation, t_type value) |
| Adds an equation part at a position determined by order-of-operations priority. | |
| void | refreshVariables () |
| Refreshes all variable locations in the equation stack using the currently stored variable values. | |
| void | setVariable (const StringView &var, t_type value) |
| Sets the value of a named variable and updates all locations in the equation stack that reference it. | |
| t_type | solve () const |
| Solves the entire equation by evaluating the equation stack from the beginning. | |
| t_type | solve (t_type start, uint04 ¤t_index) const |
| Recursively solves the equation stack starting from the given index, accumulating onto a starting value. | |
Static Public Member Functions | |
| static uint04 | getOrderPriority (const char op) |
| Returns the order-of-operations priority for the given operator. | |
| static t_type | solve (t_type left, const char op, t_type right) |
| Solves a single binary or unary operation given a left operand, operator, and right operand. | |
Public Attributes | |
| Buffer< EquationPart > | m_equation_stack |
| The ordered stack of equation parts representing the formula. | |
| Dictionary< String, Buffer< uint04 > > | m_variable_locations |
| Maps variable names to their indices within the equation stack. | |
| Dictionary< String, t_type > | m_variables |
| Maps variable names to their current numeric values. | |
A solvable mathematical formula composed of variables, numbers, and operations.
Definition at line 44 of file Equation.h.
|
inline |
Default constructor.
Creates an empty equation with no parts or variables.
Definition at line 50 of file Equation.h.
Appends a variable-referencing equation part to the equation stack.
| [in] | operation | The operator character for this part. |
| [in] | value | The name of the variable referenced by this part. |
Definition at line 177 of file Equation.h.
References m_equation_stack, m_variable_locations, Equation< t_type >::EquationPart::operation, and Equation< t_type >::EquationPart::value.
|
inline |
Appends a numeric equation part to the equation stack.
| [in] | operation | The operator character for this part. |
| [in] | value | The numeric value for this part. |
Definition at line 130 of file Equation.h.
References m_equation_stack, Equation< t_type >::EquationPart::operation, and Equation< t_type >::EquationPart::value.
|
inline |
Adds an equation part at a position determined by order-of-operations priority.
| [in] | operation | The operator character for this part. |
| [in] | value | The numeric value for this part. |
Definition at line 164 of file Equation.h.
References m_equation_stack, Equation< t_type >::EquationPart::operation, and Equation< t_type >::EquationPart::value.
Returns the order-of-operations priority for the given operator.
| [in] | op | The operator character. |
Definition at line 142 of file Equation.h.
|
inline |
Sets the value of a named variable and updates all locations in the equation stack that reference it.
| [in] | var | The name of the variable to set. |
| [in] | value | The numeric value to assign to the variable. |
Definition at line 65 of file Equation.h.
References m_equation_stack, m_variable_locations, and m_variables.
|
inline |
Solves the entire equation by evaluating the equation stack from the beginning.
Definition at line 116 of file Equation.h.
References cast(), m_equation_stack, and solve().
|
inlinestatic |
Solves a single binary or unary operation given a left operand, operator, and right operand.
| [in] | left | The left-hand operand. |
| [in] | op | The operator character. |
| [in] | right | The right-hand operand. |
Definition at line 94 of file Equation.h.
|
inline |
Recursively solves the equation stack starting from the given index, accumulating onto a starting value.
| [in] | start | The initial accumulated value to build upon. |
| [in] | current_index | The current position in the equation stack; advanced as parts are consumed. |
Definition at line 193 of file Equation.h.
References cast(), cos(), IsInvalid(), m_equation_stack, sin(), solve(), sqrt(), and tan().