Embedded functions within HL class and removing from main
This commit is contained in:
parent
b6c266add0
commit
1ea74d9021
Binary file not shown.
Binary file not shown.
BIN
build/libHLlib.a
BIN
build/libHLlib.a
Binary file not shown.
BIN
build/main
BIN
build/main
Binary file not shown.
@ -26,7 +26,7 @@ void HL::print_sol()
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Divide and Conquer Strategy using recursive call to divide ls and merge using merge()
|
//Divide and Conquer Strategy using recursive call to divide ls and merge using merge()
|
||||||
std::set<Line> HL::gen_sol(std::set<Line>& ls){
|
std::set<Line> HL::gen_sol(const std::set<Line>& ls){
|
||||||
HL inst = *this;
|
HL inst = *this;
|
||||||
if (ls.size() > 2){
|
if (ls.size() > 2){
|
||||||
|
|
||||||
@ -129,6 +129,14 @@ std::set<Line> HL::construct_HWprob(){
|
|||||||
lines.insert(newline);
|
lines.insert(newline);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::cout << "Sorted Lines by slope:" << std::endl;
|
||||||
|
for(Line line : lines)
|
||||||
|
{
|
||||||
|
std::cout << "Line " << line.get_id() << " has slope " << line.get_slope()
|
||||||
|
<< " and a y-intercept of " << line.get_ycept() << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
return lines;
|
return lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -10,7 +10,7 @@ class HL
|
|||||||
HL();
|
HL();
|
||||||
|
|
||||||
void print_sol();
|
void print_sol();
|
||||||
std::set<Line> gen_sol(std::set<Line>& ls);
|
std::set<Line> gen_sol(const std::set<Line>& ls);
|
||||||
std::set<Line> construct_HWprob();
|
std::set<Line> construct_HWprob();
|
||||||
|
|
||||||
std::set<Line> get_lines() const;
|
std::set<Line> get_lines() const;
|
||||||
|
|||||||
12
src/main.cpp
12
src/main.cpp
@ -12,17 +12,9 @@ int main(int argc, char *argv[])
|
|||||||
std::cout << "Constructing Problem..." << std::endl;
|
std::cout << "Constructing Problem..." << std::endl;
|
||||||
HL inst = HL();
|
HL inst = HL();
|
||||||
|
|
||||||
std::set<Line> lines = inst.get_lines();
|
|
||||||
|
|
||||||
std::cout << "Sorted Lines by slope:" << std::endl;
|
|
||||||
for(Line line : lines)
|
|
||||||
{
|
|
||||||
std::cout << "Line " << line.get_id() << " has slope " << line.get_slope()
|
|
||||||
<< " and a y-intercept of " << line.get_ycept() << std::endl;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::cout << "Generating Solution." << std::endl;
|
std::cout << "Generating Solution." << std::endl;
|
||||||
inst.gen_sol(lines);
|
inst.gen_sol(inst.get_lines());
|
||||||
|
|
||||||
std::cout << "Solution is: " << std::endl;
|
std::cout << "Solution is: " << std::endl;
|
||||||
inst.print_sol();
|
inst.print_sol();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user