Bug fixes for C++ impl
This commit is contained in:
parent
28b93305cf
commit
203786726b
1 changed files with 4 additions and 4 deletions
|
@ -130,9 +130,12 @@ void Helpers::printGreedyTextJustification(unsigned long long width, const std::
|
||||||
std::vector<std::string> currentLine;
|
std::vector<std::string> currentLine;
|
||||||
unsigned long long currentToken = 0;
|
unsigned long long currentToken = 0;
|
||||||
unsigned long long size = 0;
|
unsigned long long size = 0;
|
||||||
while(true) {
|
while(currentToken < tokens.size()) {
|
||||||
size += tokens.at(currentToken).size();
|
size += tokens.at(currentToken).size();
|
||||||
if(size + 1 >= width) {
|
if(size + 1 >= width) {
|
||||||
|
if(currentLine.empty()) {
|
||||||
|
currentLine.push_back(tokens.at(currentToken++));
|
||||||
|
}
|
||||||
printCurrentLine(currentLine);
|
printCurrentLine(currentLine);
|
||||||
size = 0;
|
size = 0;
|
||||||
continue;
|
continue;
|
||||||
|
@ -140,9 +143,6 @@ void Helpers::printGreedyTextJustification(unsigned long long width, const std::
|
||||||
currentLine.push_back(tokens.at(currentToken));
|
currentLine.push_back(tokens.at(currentToken));
|
||||||
size += 1;
|
size += 1;
|
||||||
++currentToken;
|
++currentToken;
|
||||||
if(currentToken >= tokens.size()) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!currentLine.empty()) {
|
if(!currentLine.empty()) {
|
||||||
|
|
Loading…
Reference in a new issue