ADS
Algorithms and Data Structures
Toggle main menu visibility
Loading...
Searching...
No Matches
ExpressionTree.h
Go to the documentation of this file.
1
/*--------------------------------------------------------------------------*/
2
/*------------------------- File ExpressionTree.h --------------------------*/
3
/*--------------------------------------------------------------------------*/
36
/*--------------------------------------------------------------------------*/
37
/*----------------------------- DEFINITIONS --------------------------------*/
38
/*--------------------------------------------------------------------------*/
39
40
#ifndef __ADS_ExpressionTree
41
#define __ADS_ExpressionTree
42
/* self-identification: #endif constant */
43
44
/*--------------------------------------------------------------------------*/
45
/*------------------------------ INCLUDES ----------------------------------*/
46
/*--------------------------------------------------------------------------*/
47
48
#include "
ADS/Contract.h
"
49
#include "
ADS/stack/ArrayStack.h
"
50
#include "
ADS/tree/BinaryTree.h
"
51
52
#include <cmath>
53
#include <map>
54
#include <string>
55
#include <string_view>
56
#include <utility>
57
#include <vector>
58
59
/*--------------------------------------------------------------------------*/
60
/*--------------------------- NAMESPACE ------------------------------------*/
61
/*--------------------------------------------------------------------------*/
62
63
namespace
ADS
64
{
65
87
BinaryTree< std::string >
*
expressionTree
( std::string_view e );
88
107
double
evaluate
(
const
BinaryTree< std::string >
* t ,
108
const
std::map< std::string , double > & env = {} );
109
113
std::string
prefixForm
(
const
BinaryTree< std::string >
* t );
114
130
std::string
infixForm
(
const
BinaryTree< std::string >
* t );
131
132
/*--------------------------------------------------------------------------*/
133
134
}
// end( namespace ADS )
135
136
/*--------------------------------------------------------------------------*/
137
/*-------------------------- IMPLEMENTATION --------------------------------*/
138
/*--------------------------------------------------------------------------*/
139
140
#include "ADS/tree/impl/ExpressionTree.tpp"
141
142
/*--------------------------------------------------------------------------*/
143
144
#endif
/* ExpressionTree.h included */
145
146
/*--------------------------------------------------------------------------*/
147
/*----------------------- End File ExpressionTree.h ------------------------*/
148
/*--------------------------------------------------------------------------*/
ArrayStack.h
The STACK of the book [see ADT.h] realized with a vector of a given capacity : the items are in the ...
BinaryTree.h
The binary TREE of the book: an ordered tree where each node has at most two children,...
Contract.h
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
ADS::BinaryTree
a binary tree with pointers to the parent and to the two children
Definition
BinaryTree.h:104
ADS::prefixForm
std::string prefixForm(const BinaryTree< std::string > *t)
the prefix form of , each subtree in parentheses, by a previsit (section 5.6)
ADS::expressionTree
BinaryTree< std::string > * expressionTree(std::string_view e)
the expression tree of the postfix expression , whose tokens are separated by spaces; the caller owns...
ADS::infixForm
std::string infixForm(const BinaryTree< std::string > *t)
the infix form of , fully parenthesized, by an invisit (section 5.6)
ADS::evaluate
double evaluate(const BinaryTree< std::string > *t, const std::map< std::string, double > &env={})
the value of the expression , with the variables valued by env; a leaf is a number,...
ADS
Definition
ADT.h:96
ADS
tree
ExpressionTree.h
Generated by
1.17.0