From 38cc28167e02a33c44e216c4674524e0afae239f Mon Sep 17 00:00:00 2001 From: realstealthninja Date: Thu, 25 Sep 2025 07:15:45 +0000 Subject: [PATCH] Documentation for 07663b019b592509cc69048bfcf3af4761ec13e5 --- d5/dc8/postfix__evaluation_8cpp__incl.map | 24 +-- d5/dc8/postfix__evaluation_8cpp__incl.md5 | 2 +- d5/dc8/postfix__evaluation_8cpp__incl.svg | 52 +++--- d5/dc8/postfix__evaluation_8cpp__incl_org.svg | 52 +++--- d7/d75/postfix__evaluation_8cpp.html | 150 ++++++++---------- d7/d75/postfix__evaluation_8cpp.js | 2 +- d7/d75/postfix__evaluation_8cpp_source.html | 148 +++++++++-------- doxygen_crawl.html | 2 +- search/all_15.js | 2 +- search/functions_10.js | 2 +- 10 files changed, 210 insertions(+), 226 deletions(-) diff --git a/d5/dc8/postfix__evaluation_8cpp__incl.map b/d5/dc8/postfix__evaluation_8cpp__incl.map index bd15e1144..65646d7a0 100644 --- a/d5/dc8/postfix__evaluation_8cpp__incl.map +++ b/d5/dc8/postfix__evaluation_8cpp__incl.map @@ -1,15 +1,15 @@ - + - - - - - - - - - - - + + + + + + + + + + + diff --git a/d5/dc8/postfix__evaluation_8cpp__incl.md5 b/d5/dc8/postfix__evaluation_8cpp__incl.md5 index bb2f23cb8..c61ab7a20 100644 --- a/d5/dc8/postfix__evaluation_8cpp__incl.md5 +++ b/d5/dc8/postfix__evaluation_8cpp__incl.md5 @@ -1 +1 @@ -de5707406ee8a27095e1dcbe0a2a0239 \ No newline at end of file +065f952c219db43861d43f31d5426619 \ No newline at end of file diff --git a/d5/dc8/postfix__evaluation_8cpp__incl.svg b/d5/dc8/postfix__evaluation_8cpp__incl.svg index b1cec4624..939081740 100644 --- a/d5/dc8/postfix__evaluation_8cpp__incl.svg +++ b/d5/dc8/postfix__evaluation_8cpp__incl.svg @@ -4,8 +4,8 @@ - + @@ -23,8 +23,8 @@ Node1 - -others/postfix_evaluation.cpp + +others/postfix_evaluation.cpp @@ -41,8 +41,8 @@ Node1->Node2 - - + + @@ -50,8 +50,8 @@ Node3 - -array + +cassert @@ -59,8 +59,8 @@ Node1->Node3 - - + + @@ -68,8 +68,8 @@ Node4 - -cassert + +iostream @@ -77,8 +77,8 @@ Node1->Node4 - - + + @@ -86,8 +86,8 @@ Node5 - -iostream + +stack @@ -95,8 +95,8 @@ Node1->Node5 - - + + @@ -104,8 +104,8 @@ Node6 - -stack + +string @@ -113,8 +113,8 @@ Node1->Node6 - - + + @@ -122,8 +122,8 @@ Node7 - -string + +vector @@ -131,8 +131,8 @@ Node1->Node7 - - + + diff --git a/d5/dc8/postfix__evaluation_8cpp__incl_org.svg b/d5/dc8/postfix__evaluation_8cpp__incl_org.svg index 35838e0ad..c3ce372e4 100644 --- a/d5/dc8/postfix__evaluation_8cpp__incl_org.svg +++ b/d5/dc8/postfix__evaluation_8cpp__incl_org.svg @@ -4,16 +4,16 @@ - + others/postfix_evaluation.cpp Node1 - -others/postfix_evaluation.cpp + +others/postfix_evaluation.cpp @@ -30,8 +30,8 @@ Node1->Node2 - - + + @@ -39,8 +39,8 @@ Node3 - -array + +cassert @@ -48,8 +48,8 @@ Node1->Node3 - - + + @@ -57,8 +57,8 @@ Node4 - -cassert + +iostream @@ -66,8 +66,8 @@ Node1->Node4 - - + + @@ -75,8 +75,8 @@ Node5 - -iostream + +stack @@ -84,8 +84,8 @@ Node1->Node5 - - + + @@ -93,8 +93,8 @@ Node6 - -stack + +string @@ -102,8 +102,8 @@ Node1->Node6 - - + + @@ -111,8 +111,8 @@ Node7 - -string + +vector @@ -120,8 +120,8 @@ Node1->Node7 - - + + diff --git a/d7/d75/postfix__evaluation_8cpp.html b/d7/d75/postfix__evaluation_8cpp.html index 0bec6b1a9..5817d51e0 100644 --- a/d7/d75/postfix__evaluation_8cpp.html +++ b/d7/d75/postfix__evaluation_8cpp.html @@ -120,15 +120,15 @@ $(function(){initNavTree('d7/d75/postfix__evaluation_8cpp.html','../../',''); })

Evaluation of Postfix Expression More...

#include <algorithm>
-#include <array>
#include <cassert>
#include <iostream>
#include <stack>
#include <string>
+#include <vector>
Include dependency graph for postfix_evaluation.cpp:
-
+

Go to the source code of this file.

@@ -146,9 +146,8 @@ Functions  Checks if scanned string is a number.
void others::postfix_expression::evaluate (float a, float b, const std::string &operation, std::stack< float > &stack)  Evaluate answer using given last two operands from and operation.
-template<std::size_t N> -float others::postfix_expression::postfix_evaluation (std::array< std::string, N > input) - Postfix Evaluation algorithm to compute the value from given input array.
+float others::postfix_expression::postfix_evaluation (const std::vector< std::string > &input) + Postfix Evaluation algorithm to compute the value from given input array.
static void test_function_1 ()  Test function 1 with input array {'2', '3', '1', '*', '+', '9', '-'}.
static void test_function_2 () @@ -289,78 +288,67 @@ Functions

Main function.

Returns
0 on exit
-

Definition at line 156 of file postfix_evaluation.cpp.

-
156 {
- - -
159 test_function_3();
-
160
-
161 std::cout << "\nTest implementations passed!\n";
-
162
-
163 return 0;
-
164}
-
static void test_function_2()
Test function 2 with input array {'100', '200', '+', '2', '/', '5', '*', '7', '+'}...
-
static void test_function_1()
Test function 1 with input array {'2', '3', '1', '*', '+', '9', '-'}.
+

Definition at line 151 of file postfix_evaluation.cpp.

+
151 {
+ + +
154 test_function_3();
+
155
+
156 std::cout << "\nTest implementations passed!\n";
+
157
+
158 return 0;
+
159}
+
static void test_function_2()
Test function 2 with input array {'100', '200', '+', '2', '/', '5', '*', '7', '+'}...
+
static void test_function_1()
Test function 1 with input array {'2', '3', '1', '*', '+', '9', '-'}.
- -

◆ postfix_evaluation()

+ +

◆ postfix_evaluation()

-
-template<std::size_t N>
- +
float others::postfix_expression::postfix_evaluation (std::array< std::string, N > input)const std::vector< std::string > & input)

Postfix Evaluation algorithm to compute the value from given input array.

-
Template Parameters
- - -
Nnumber of array size
-
-
Parameters
- +
inputArray of characters consisting of numbers and operations
inputvector of strings consisting of numbers and operations
Returns
stack[stackTop] returns the top value from the stack
-

Definition at line 88 of file postfix_evaluation.cpp.

-
88 {
-
89 std::stack<float> stack;
-
90 int j = 0;
-
91
-
92 while (j < N) {
-
93 std::string scan = input[j];
-
94 if (is_number(scan)) {
-
95 stack.push(std::stof(scan));
-
96
-
97 } else {
-
98 const float op2 = stack.top();
-
99 stack.pop();
-
100 const float op1 = stack.top();
-
101 stack.pop();
+

Definition at line 86 of file postfix_evaluation.cpp.

+
86 {
+
87 std::stack<float> stack;
+
88
+
89 for (const auto &scan : input) {
+
90 if (is_number(scan)) {
+
91 stack.push(std::stof(scan));
+
92
+
93 } else {
+
94 const float op2 = stack.top();
+
95 stack.pop();
+
96 const float op1 = stack.top();
+
97 stack.pop();
+
98
+
99 evaluate(op1, op2, scan, stack);
+
100 }
+
101 }
102
-
103 evaluate(op1, op2, scan, stack);
-
104 }
-
105 j++;
-
106 }
-
107
-
108 std::cout << stack.top() << "\n";
-
109
-
110 return stack.top();
-
111}
+
103 std::cout << stack.top() << "\n";
+
104
+
105 return stack.top();
+
106}
void pop()
Definition stack.hpp:62
value_type top() const
Definition stack.hpp:56
char stack[MAX]
@@ -394,15 +382,15 @@ template<std::size_t N>

Test function 1 with input array {'2', '3', '1', '*', '+', '9', '-'}.

Returns
none
-

Definition at line 120 of file postfix_evaluation.cpp.

-
120 {
-
121 std::array<std::string, 7> input = {"2", "3", "1", "*", "+", "9", "-"};
-
122
- -
124
-
125 assert(answer == -4);
-
126}
-
float postfix_evaluation(std::array< std::string, N > input)
Postfix Evaluation algorithm to compute the value from given input array.
+

Definition at line 115 of file postfix_evaluation.cpp.

+
115 {
+
116 std::vector<std::string> input = {"2", "3", "1", "*", "+", "9", "-"};
+
117
+ +
119
+
120 assert(answer == -4);
+
121}
+
float postfix_evaluation(const std::vector< std::string > &input)
Postfix Evaluation algorithm to compute the value from given input array.
@@ -432,14 +420,14 @@ template<std::size_t N>

Test function 2 with input array {'100', '200', '+', '2', '/', '5', '*', '7', '+'}.

Returns
none
-

Definition at line 133 of file postfix_evaluation.cpp.

-
133 {
-
134 std::array<std::string, 9> input = {"100", "200", "+", "2", "/",
-
135 "5", "*", "7", "+"};
- -
137
-
138 assert(answer == 757);
-
139}
+

Definition at line 128 of file postfix_evaluation.cpp.

+
128 {
+
129 std::vector<std::string> input = {"100", "200", "+", "2", "/",
+
130 "5", "*", "7", "+"};
+ +
132
+
133 assert(answer == 757);
+
134}
@@ -466,17 +454,17 @@ template<std::size_t N>
-

Definition at line 141 of file postfix_evaluation.cpp.

-
141 {
-
142 std::array<std::string, 43> input = {
-
143 "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1",
-
144 "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1",
-
145 "+", "+", "+", "+", "+", "+", "+", "+", "+", "+", "+",
-
146 "+", "+", "+", "+", "+", "+", "+", "+", "+", "+"};
- -
148
-
149 assert(answer == 22);
-
150}
+

Definition at line 136 of file postfix_evaluation.cpp.

+
136 {
+
137 std::vector<std::string> input = {
+
138 "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1",
+
139 "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1",
+
140 "+", "+", "+", "+", "+", "+", "+", "+", "+", "+", "+",
+
141 "+", "+", "+", "+", "+", "+", "+", "+", "+", "+"};
+ +
143
+
144 assert(answer == 22);
+
145}
diff --git a/d7/d75/postfix__evaluation_8cpp.js b/d7/d75/postfix__evaluation_8cpp.js index 347a96c55..54aad578d 100644 --- a/d7/d75/postfix__evaluation_8cpp.js +++ b/d7/d75/postfix__evaluation_8cpp.js @@ -3,7 +3,7 @@ var postfix__evaluation_8cpp = [ "others::postfix_expression::evaluate", "d7/d75/postfix__evaluation_8cpp.html#a19d995518723c1bc69718c3c33381e30", null ], [ "others::postfix_expression::is_number", "d7/d75/postfix__evaluation_8cpp.html#a4c27f949c9d6659be9f5bd2ccbe1360a", null ], [ "main", "d7/d75/postfix__evaluation_8cpp.html#ae66f6b31b5ad750f1fe042a706a4e3d4", null ], - [ "others::postfix_expression::postfix_evaluation", "d7/d75/postfix__evaluation_8cpp.html#ae38bd3a177a6d61da3859a281233bbe1", null ], + [ "others::postfix_expression::postfix_evaluation", "d7/d75/postfix__evaluation_8cpp.html#a55fe33d236f61f7a87548f031418bfa0", null ], [ "test_function_1", "d7/d75/postfix__evaluation_8cpp.html#a6a8eeb7d346d5cd6335d9780fb7c0f15", null ], [ "test_function_2", "d7/d75/postfix__evaluation_8cpp.html#a5b97d12e8b61484f756a8721992bfae1", null ] ]; \ No newline at end of file diff --git a/d7/d75/postfix__evaluation_8cpp_source.html b/d7/d75/postfix__evaluation_8cpp_source.html index e15e122f6..ebf354249 100644 --- a/d7/d75/postfix__evaluation_8cpp_source.html +++ b/d7/d75/postfix__evaluation_8cpp_source.html @@ -118,11 +118,11 @@ $(function(){initNavTree('d7/d75/postfix__evaluation_8cpp_source.html','../../',
Go to the documentation of this file.
1
14#include <algorithm> // for all_of
-
15#include <array> // for array
-
16#include <cassert> // for assert
-
17#include <iostream> // for io operations
-
18#include <stack> // for std::stack
-
19#include <string> // for stof
+
15#include <cassert> // for assert
+
16#include <iostream> // for io operations
+
17#include <stack> // for std::stack
+
18#include <string> // for stof
+
19#include <vector> // for std::vector
20
25namespace others {
30namespace postfix_expression {
@@ -166,77 +166,73 @@ $(function(){initNavTree('d7/d75/postfix__evaluation_8cpp_source.html','../../',
78}
79
-
87template <std::size_t N>
-
-
88float postfix_evaluation(std::array<std::string, N> input) {
-
89 std::stack<float> stack;
-
90 int j = 0;
-
91
-
92 while (j < N) {
-
93 std::string scan = input[j];
-
94 if (is_number(scan)) {
-
95 stack.push(std::stof(scan));
-
96
-
97 } else {
-
98 const float op2 = stack.top();
-
99 stack.pop();
-
100 const float op1 = stack.top();
-
101 stack.pop();
+
+
86float postfix_evaluation(const std::vector<std::string> &input) {
+
87 std::stack<float> stack;
+
88
+
89 for (const auto &scan : input) {
+
90 if (is_number(scan)) {
+
91 stack.push(std::stof(scan));
+
92
+
93 } else {
+
94 const float op2 = stack.top();
+
95 stack.pop();
+
96 const float op1 = stack.top();
+
97 stack.pop();
+
98
+
99 evaluate(op1, op2, scan, stack);
+
100 }
+
101 }
102
-
103 evaluate(op1, op2, scan, stack);
-
104 }
-
105 j++;
-
106 }
-
107
-
108 std::cout << stack.top() << "\n";
-
109
-
110 return stack.top();
-
111}
+
103 std::cout << stack.top() << "\n";
+
104
+
105 return stack.top();
+
106}
-
112} // namespace postfix_expression
-
113} // namespace others
-
114
-
-
120static void test_function_1() {
-
121 std::array<std::string, 7> input = {"2", "3", "1", "*", "+", "9", "-"};
-
122
- -
124
-
125 assert(answer == -4);
-
126}
+
107} // namespace postfix_expression
+
108} // namespace others
+
109
+
+
115static void test_function_1() {
+
116 std::vector<std::string> input = {"2", "3", "1", "*", "+", "9", "-"};
+
117
+ +
119
+
120 assert(answer == -4);
+
121}
-
127
-
-
133static void test_function_2() {
-
134 std::array<std::string, 9> input = {"100", "200", "+", "2", "/",
-
135 "5", "*", "7", "+"};
- -
137
-
138 assert(answer == 757);
-
139}
+
122
+
+
128static void test_function_2() {
+
129 std::vector<std::string> input = {"100", "200", "+", "2", "/",
+
130 "5", "*", "7", "+"};
+ +
132
+
133 assert(answer == 757);
+
134}
-
140
-
141static void test_function_3() {
-
142 std::array<std::string, 43> input = {
-
143 "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1",
-
144 "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1",
-
145 "+", "+", "+", "+", "+", "+", "+", "+", "+", "+", "+",
-
146 "+", "+", "+", "+", "+", "+", "+", "+", "+", "+"};
- -
148
-
149 assert(answer == 22);
-
150}
-
151
-
-
156int main() {
- - -
159 test_function_3();
-
160
-
161 std::cout << "\nTest implementations passed!\n";
-
162
-
163 return 0;
-
164}
+
135
+
136static void test_function_3() {
+
137 std::vector<std::string> input = {
+
138 "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1",
+
139 "1", "1", "1", "1", "1", "1", "1", "1", "1", "1", "1",
+
140 "+", "+", "+", "+", "+", "+", "+", "+", "+", "+", "+",
+
141 "+", "+", "+", "+", "+", "+", "+", "+", "+", "+"};
+ +
143
+
144 assert(answer == 22);
+
145}
+
146
+
+
151int main() {
+ + +
154 test_function_3();
+
155
+
156 std::cout << "\nTest implementations passed!\n";
+
157
+
158 return 0;
+
159}
for std::invalid_argument
Definition stack.hpp:19
void pop()
Definition stack.hpp:62
@@ -246,10 +242,10 @@ $(function(){initNavTree('d7/d75/postfix__evaluation_8cpp_source.html','../../',
Functions for Postfix Expression algorithm.
void evaluate(float a, float b, const std::string &operation, std::stack< float > &stack)
Evaluate answer using given last two operands from and operation.
bool is_number(const std::string &s)
Checks if scanned string is a number.
-
static void test_function_2()
Test function 2 with input array {'100', '200', '+', '2', '/', '5', '*', '7', '+'}...
-
static void test_function_1()
Test function 1 with input array {'2', '3', '1', '*', '+', '9', '-'}.
-
float postfix_evaluation(std::array< std::string, N > input)
Postfix Evaluation algorithm to compute the value from given input array.
-
int main()
Main function.
+
float postfix_evaluation(const std::vector< std::string > &input)
Postfix Evaluation algorithm to compute the value from given input array.
+
static void test_function_2()
Test function 2 with input array {'100', '200', '+', '2', '/', '5', '*', '7', '+'}...
+
static void test_function_1()
Test function 1 with input array {'2', '3', '1', '*', '+', '9', '-'}.
+
int main()
Main function.
diff --git a/doxygen_crawl.html b/doxygen_crawl.html index 2196e6a4f..53a730ce5 100644 --- a/doxygen_crawl.html +++ b/doxygen_crawl.html @@ -1484,9 +1484,9 @@ + - diff --git a/search/all_15.js b/search/all_15.js index 5b43b7fe1..4597a3e04 100644 --- a/search/all_15.js +++ b/search/all_15.js @@ -50,7 +50,7 @@ var searchData= ['pop_5ffront_47',['pop_front',['../d8/d77/namespacemachine__learning.html#a912cf68863063a38d6e63545be5eb093',1,'machine_learning']]], ['populate_5fparents_48',['populate_parents',['../d0/d58/classgraph_1_1_rooted_tree.html#ae6928f3ebd491541e9570e746b877c1e',1,'graph::RootedTree']]], ['populate_5fup_49',['populate_up',['../d9/d23/classgraph_1_1_lowest_common_ancestor.html#a42589cc39d6bbff6c997152f1b96e356',1,'graph::LowestCommonAncestor']]], - ['postfix_5fevaluation_50',['postfix_evaluation',['../d7/d75/postfix__evaluation_8cpp.html#ae38bd3a177a6d61da3859a281233bbe1',1,'others::postfix_expression']]], + ['postfix_5fevaluation_50',['postfix_evaluation',['../d7/d75/postfix__evaluation_8cpp.html#a55fe33d236f61f7a87548f031418bfa0',1,'others::postfix_expression']]], ['postfix_5fevaluation_2ecpp_51',['postfix_evaluation.cpp',['../d7/d75/postfix__evaluation_8cpp.html',1,'']]], ['postfix_5fexpression_52',['postfix_expression',['../d4/de6/namespacepostfix__expression.html',1,'']]], ['postorder_53',['postorder',['../dd/de1/classothers_1_1recursive__tree__traversals_1_1_b_t.html#ac9404b65f407f631915515fa2e08a40c',1,'others::recursive_tree_traversals::BT']]], diff --git a/search/functions_10.js b/search/functions_10.js index c70623b14..c6ad40a66 100644 --- a/search/functions_10.js +++ b/search/functions_10.js @@ -21,7 +21,7 @@ var searchData= ['pop_5ffront_18',['pop_front',['../d8/d77/namespacemachine__learning.html#a912cf68863063a38d6e63545be5eb093',1,'machine_learning']]], ['populate_5fparents_19',['populate_parents',['../d0/d58/classgraph_1_1_rooted_tree.html#ae6928f3ebd491541e9570e746b877c1e',1,'graph::RootedTree']]], ['populate_5fup_20',['populate_up',['../d9/d23/classgraph_1_1_lowest_common_ancestor.html#a42589cc39d6bbff6c997152f1b96e356',1,'graph::LowestCommonAncestor']]], - ['postfix_5fevaluation_21',['postfix_evaluation',['../d7/d75/postfix__evaluation_8cpp.html#ae38bd3a177a6d61da3859a281233bbe1',1,'others::postfix_expression']]], + ['postfix_5fevaluation_21',['postfix_evaluation',['../d7/d75/postfix__evaluation_8cpp.html#a55fe33d236f61f7a87548f031418bfa0',1,'others::postfix_expression']]], ['postorder_22',['postorder',['../dd/de1/classothers_1_1recursive__tree__traversals_1_1_b_t.html#ac9404b65f407f631915515fa2e08a40c',1,'others::recursive_tree_traversals::BT']]], ['postorderiterative_23',['postOrderIterative',['../d9/d12/classothers_1_1iterative__tree__traversals_1_1_binary_tree.html#a636a07c90b7f312bb86d2ec104efca25',1,'others::iterative_tree_traversals::BinaryTree']]], ['power_24',['power',['../de/dc3/fibonacci__sum_8cpp.html#a7cf5feaf168b88e74544da59ed830311',1,'math::fibonacci_sum::power()'],['../df/d72/modular__division_8cpp.html#a66cdf93153cbd1408bd74ac68961d179',1,'math::modular_division::power()'],['../dd/d47/namespacemath.html#afcd07701d73ed65cd616bcba02737f3d',1,'math::power()'],['../df/def/power__for__huge__numbers_8cpp.html#ae249a2af508aa94266023ce8aa81426f',1,'power(int x, int n): power_for_huge_numbers.cpp'],['../d7/d35/matrix__exponentiation_8cpp.html#a702a9fc90e79b05b863cc4efa26ae2ec',1,'power(const vector< vector< ll > > &A, ll p): matrix_exponentiation.cpp']]],