File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33
44class Vector2D {
55public:
6- Vector2D (vector<vector<int >>& vec2d) {
7- it1 = vec2d.begin ();
8- it1_end = vec2d.end ();
9- if (it1 != it1_end) {
10- it2 = it1->begin ();
11- it2_end = it1->end ();
6+ Vector2D (vector<vector<int >>& vec2d) : vec(vec2d) {
7+ x = vec.begin ();
8+ if (x != vec.end ()) {
9+ y = x->begin ();
1210 adjustNextIter ();
1311 }
1412 }
1513
1614 int next () {
17- const auto ret = *it2 ;
18- ++it2 ;
15+ const auto ret = *y ;
16+ ++y ;
1917 adjustNextIter ();
2018 return ret;
2119 }
2220
2321 bool hasNext () {
24- return it1 != it1_end && it2 != it2_end ;
22+ return x != vec. end () && y != x-> end () ;
2523 }
2624
2725 void adjustNextIter () {
28- while (it1 != it1_end && it2 == it2_end) {
29- ++it1;
30- if (it1 != it1_end) {
31- it2 = it1->begin ();
32- it2_end = it1->end ();
26+ while (x != vec.end () && y == x->end ()) {
27+ ++x;
28+ if (x != vec.end ()) {
29+ y = x->begin ();
3330 }
3431 }
3532 }
3633
3734private:
38- vector<vector<int >>::iterator it1;
39- vector<vector<int >>::iterator it1_end;
40- vector<int >::iterator it2;
41- vector<int >::iterator it2_end;
35+ vector<vector<int >>& vec;
36+ vector<vector<int >>::iterator x;
37+ vector<int >::iterator y;
4238};
You can’t perform that action at this time.
0 commit comments