栈
0.1
数据结构_第3章
|
< 后缀式的元素: 操作数, 操作符 More...
Public Types | |
enum | Item_type { Item_type::Operand, Item_type::Operator } |
< 项的类型 More... | |
enum | Operator_type : int8_t { Operator_type::NAO = (int8_t)0xFF, Operator_type::Add = 0x10, Operator_type::Sub = 0x11, Operator_type::Mul = 0x20, Operator_type::Div = 0x21, Operator_type::Exp = 0x30, Operator_type::Oparen = 0x01, Operator_type::Cparen = 0x02 } |
Public Member Functions | |
Item (Item_type item_type, Operator_type operator_type, double operand_val=NAN) | |
Construct a new Item object. More... | |
Item (double operand_val) | |
Construct a new Item object. More... | |
Item (Operator_type op=Operator_type::NAO) | |
Construct a new Item object. More... | |
bool | hasLoPriThan (const Item &rhs) const |
Item内嵌类的工具函数 More... | |
bool | isOperator () const |
是操作符 More... | |
bool | isOperand () const |
是操作数 More... | |
bool | isNAO () const |
是NAO? More... | |
int8_t | priority () const |
获取优先级. More... | |
Static Public Member Functions | |
static Item | nao () |
获得一个NAO(非法操作符) More... | |
static Item | excOp (const Item &op, const Item &opL=nao(), const Item &opR=nao()) |
执行一次运算. More... | |
Public Attributes | |
Item_type | item_type |
项的类型 More... | |
Operator_type | operator_type |
操作符类型 More... | |
double | operand_val = NAN |
操作数的值(为操作符时, 无效) More... | |
Static Public Attributes | |
static const int8_t | priOfAdd = static_cast<int8_t>(Operator_type::Add) >> 4 |
二元加法的优先级(同减法) More... | |
static const int8_t | priOfMul = static_cast<int8_t>(Operator_type::Mul) >> 4 |
二元乘法的优先级(同除法) More... | |
Friends | |
bool | operator== (const Item &lhs, const Item &rhs) |
operator== More... | |
|
strong |
|
strong |
|
inline |
|
inlineexplicit |
|
inlineexplicit |
|
static |
执行一次运算.
op | |
opL | |
opR |
Definition at line 702 of file Rpn.hh.
References isNAO(), isOperand(), isOperator(), operand_val, and operator_type.
Referenced by RPN::Rpn_t::calcVal().
bool RPN::Rpn_t::Item::hasLoPriThan | ( | const Item & | rhs | ) | const |
Item内嵌类的工具函数
运算符优先级lhs < rhs. NAO(非法运算符)的优先级为最低
rhs |
Definition at line 685 of file Rpn.hh.
References item_type, Operator, and priority().
Referenced by RPN::Rpn_t::infixListToPostfixList().
|
inline |
是NAO?
Definition at line 220 of file Rpn.hh.
References isOperator(), NAO, and operator_type.
Referenced by excOp(), and RPN::Rpn_t::infixListToPostfixList().
|
inline |
|
inline |
|
inlinestatic |
|
inline |
获取优先级.
Definition at line 235 of file Rpn.hh.
References operator_type.
Referenced by hasLoPriThan(), and RPN::Rpn_t::infixListToPostfixList().
Item_type RPN::Rpn_t::Item::item_type |
项的类型
Definition at line 154 of file Rpn.hh.
Referenced by hasLoPriThan(), isOperand(), isOperator(), RPN::Rpn_t::itemToStr(), and RPN::operator==().
double RPN::Rpn_t::Item::operand_val = NAN |
操作数的值(为操作符时, 无效)
Definition at line 156 of file Rpn.hh.
Referenced by RPN::Rpn_t::calcVal(), excOp(), RPN::Rpn_t::itemToStr(), and RPN::operator==().
Operator_type RPN::Rpn_t::Item::operator_type |
操作符类型
Definition at line 155 of file Rpn.hh.
Referenced by excOp(), RPN::Rpn_t::infixListToPostfixList(), isNAO(), RPN::Rpn_t::itemToStr(), RPN::operator==(), and priority().
|
static |
二元加法的优先级(同减法)
Definition at line 252 of file Rpn.hh.
Referenced by RPN::Rpn_t::infixListToPostfixList().
|
static |
二元乘法的优先级(同除法)
Definition at line 258 of file Rpn.hh.
Referenced by RPN::Rpn_t::infixListToPostfixList().