blob: 844a337992016f8af5dfd8802f26a0956ff9b97b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#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, "");
}
|