#include "Box.h" void Box::removeUselessSubBoxes() { for (auto i = subboxes.begin(); i != subboxes.end(); ++i) { if ((*i)->items.empty() && (*i)->subboxes.size() < 2) { if ((*i)->subboxes.empty()) { subboxes.erase(i); continue; } *i = (*i)->subboxes[0]; } // else // (*i)->removeUselessSubBoxes(); } } std::ostream& Box::printWithInd(std::ostream& ostr, std::string indent) { ostr << indent << name << std::endl; for (std::string& i : items) ostr << indent << "+ " << i << std::endl; indent += " "; for (Box* sb : subboxes) sb->printWithInd(ostr, indent); return ostr; } std::ostream& Box::print(std::ostream& ostr) { return printWithInd(ostr, ""); }