39 lines
752 B
C++
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
|