int halfplane(lines &v, points &res) { sort(v.begin(), v.end(), cmpang); deque<line> q; deque<point> ans; q.push_back(v[0]); for (int i = 1; i < int(v.size()); i ++) { if (dcmp(v[i].ang - v[i - 1].ang) == 0) continue; while(ans.size() && !onleft(ans.back(), v[i])) { ans.pop_back(); q.pop_back(); } while(ans.size() && !onleft(ans.front(), v[i])) { ans.pop_front(); q.pop_front(); } ans.push_back(interpoint(q.back(), v[i])); q.push_back(v[i]); } while(ans.size() && !onleft(ans.back(), q.front())) { ans.pop_back(); q.pop_back(); } while(ans.size() && !onleft(ans.front(), q.back())) { ans.pop_front(); q.pop_front(); } ans.push_back(interpoint(q.back(), q.front())); res = points(ans.begin(), ans.end()); return ans.size(); //you must use the size to assure an empty set, area dont has the accuracy we need }
void write() { fst outs; this->_open_write(outs); outs.seekg(0, std::ios::beg); for (lines::iterator iter = _content.begin(); iter != _content.end(); ++iter) { outs << (*iter) << "\n"; } }
task4_6::solution::solution( const lines& calulator_lines ) { size_t i = 0; expressions exps; for(lines::const_iterator it = calulator_lines.begin(); it != calulator_lines.end(); it++, i++) rpn(*it, i, exps); make_values(exps); }
task4_6::solution::solution( const lines& calulator_lines ) { for (size_t i = 0; i < calulator_lines.size(); ++i) { try { calculator_.CalculateExpression(calulator_lines[i]); } catch (std::logic_error& e) { std::stringstream msg; msg << e.what() << "(line: " << i << ')'; throw std::logic_error(msg.str()); } } }
task4_6::solution::solution( const lines& calculator_lines ) { line_index = 0; for( lines::const_iterator it = calculator_lines.begin(); it!= calculator_lines.end(); ++it, ++line_index ) process_line( *it ); }