Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include<sstream>
- #include "../stringstreamenumerator.hpp"
- using namespace std;
- class MatrixSorFolytEnum: public Enumerator<pair<int3,pair<int,int>>>
- {
- public:
- ifstream _f;
- bool _end;
- pair<int3,pair<int,int>> _df;
- enum Exceptions { OPEN_ERROR };
- MatrixSorFolytEnum(string filename){
- _f.open(filename.c_str());
- if(_f.fail()) throw OPEN_ERROR;
- _end = false;
- }
- ~MatrixSorFolytEnum() {
- _f.close();
- }
- int i,j;
- StringStreamEnumerator<int3> *en;
- void first() {
- i=1;j=1;
- string line;
- getline(_f,line,'\n');
- stringstream stream(line);
- en = new StringStreamEnumerator<int3>(stream);
- en->first();
- //cout << en->current().getNum() << endl;
- }
- void next() {
- en->next();
- if (!en->end()) {
- j++;
- } else {
- j=1;
- i++;
- string line;
- getline(_f,line,'\n');
- stringstream stream(line);
- en = new StringStreamEnumerator<int3>(stream);
- en->first();
- }
- }
- bool end() const{
- return ( _f.eof() && en->end());
- }
- pair<int3,pair<int,int>> current() const {
- pair<int3,pair<int,int>> sajt;
- sajt.first=en->current();
- sajt.second.first=i;
- sajt.second.second=j;
- return sajt;
- }
- private:
- };
- #endif // MATRIXSORFOLYTENUM_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement