Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "op.hpp"
- #include "Div.hpp"
- #include "Mult.hpp"
- #include "Sub.hpp"
- #include "add.hpp"
- #include "pow.hpp"
- #include "container.hpp"
- #include "sort.hpp"
- #include <vector>
- #include "base.hpp"
- #include <algorithm>
- using namespace std;
- class VectorContainer: public Container
- {
- protected:
- vector <Base*> trees;
- Sort* sort_pointer;
- public:
- VectorContainer(): sort_pointer(nullptr) {}
- VectorContainer(Sort* sortList): sort_pointer (nullptr)
- {
- sort_function = sortList;
- }
- void set_sort_function(Sort* sort_function)
- {
- this->sort_function = sort_function;
- }
- void add_element(Base* element)
- {
- trees.push_back(element);
- }
- void print()
- {
- for (int index = 0; index < size(); ++index)
- {
- cout << trees.at(index)->stringify() << endl;
- }
- }
- void sort ()
- {
- try {sort_function->sort(this);}
- catch (Container* container)
- {
- cout << "Exception detected" << endl;
- }
- }
- void swap (int i, int j)
- {
- Base* temp;
- temp = trees.at(i);
- trees.at(i) = trees.at(j);
- trees.at(j) = temp;
- }
- Base* at(int i)
- {
- return trees.at(i);
- }
- int size()
- {
- return trees.size();
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement