This repository has been archived on 2022-05-26. You can view files and clone it, but cannot push or open issues or pull requests.
calculator/src/stack.cpp
2022-05-15 21:47:33 +02:00

39 lines
752 B
C++

#include <vector>
/**
* @brief Set of tools to manipulate vector stacks.
*/
namespace Stack
{
template <class type>
bool isEmpty(const std::vector<type>& stack) {
return stack.empty();
};
// template <class type>
// bool isFull(std::vector<type>& stack) {
// return !stack->empty();
// };
template <class type>
void put(std::vector<type>& stack, const type& item) {
stack.push_back(item);
}
template <class type>
type take(std::vector<type>& stack) {
if (stack.size() == 0) throw "a";
type toReturn = stack.back();
stack.pop_back();
return toReturn;
}
namespace oper {
template <class type>
void add(std::vector<type>& stack) {
take(stack);
// put(take(stack)+)
}
}
}; // namespace stack