ADS
Algorithms and Data Structures
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"
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
63namespace ADS
64{
65
88
108 const std::map< std::string , double > & env = {} );
109
113std::string prefixForm( const BinaryTree< std::string > * t );
114
130std::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/*--------------------------------------------------------------------------*/
The STACK of the book [see ADT.h] realized with a vector of a given capacity : the items are in the ...
The binary TREE of the book: an ordered tree where each node has at most two children,...
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
a binary tree with pointers to the parent and to the two children
Definition BinaryTree.h:104
std::string prefixForm(const BinaryTree< std::string > *t)
the prefix form of , each subtree in parentheses, by a previsit (section 5.6)
BinaryTree< std::string > * expressionTree(std::string_view e)
the expression tree of the postfix expression , whose tokens are separated by spaces; the caller owns...
std::string infixForm(const BinaryTree< std::string > *t)
the infix form of , fully parenthesized, by an invisit (section 5.6)
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,...
Definition ADT.h:96