+ if (i < max - 1){
+ Interval& curr = intervals[i];
+ curr.first = n + (*g >= 0 ? 1 : 0);
+
+ if (curr.second == max)
+ curr.oriented = *g < 0;
+ else
+ curr.oriented ^= *g < 0;
+ }
+ if (i > 0){
+ Interval& prev = intervals[i-1];
+ prev.second = n + (*g < 0 ? 1 : 0);
+
+ if (prev.first == max)
+ prev.oriented = *g < 0;
+ else
+ prev.oriented ^= *g < 0;
+ }
+