diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/line_accumulator.cc | 16 | ||||
-rw-r--r-- | src/line_accumulator.h | 5 |
2 files changed, 14 insertions, 7 deletions
diff --git a/src/line_accumulator.cc b/src/line_accumulator.cc index 95c2acd..0abe1a4 100644 --- a/src/line_accumulator.cc +++ b/src/line_accumulator.cc @@ -30,6 +30,8 @@ std::vector<std::uint8_t> getRandomIndizes( } +namespace justify { + LineAccumulator::LineAccumulator(const std::uint8_t max_length): max_length_{max_length}, device_{}, @@ -45,13 +47,13 @@ std::uint8_t LineAccumulator::getMissing() const { return this->max_length_ - this->length_; } -void LineAccumulator::operator()(const std::string& word) { - if ( ( this->length_ + word.length() ) > this->max_length_ ) { +void LineAccumulator::operator()(const std::string& token) { + if ( ( this->length_ + token.length() ) > this->max_length_ ) { this->discharge(true); } - this->tokens_.emplace_back(word, 0); - this->length_ += word.length(); + this->tokens_.emplace_back(token, 0); + this->length_ += token.length(); if ( this->length_ < this->max_length_ ) { this->tokens_.back().second += 1; @@ -129,8 +131,8 @@ void LineAccumulator::justify() { } void LineAccumulator::discharge(const bool full) { - this->length_ -= this->tokens_.back().second; - this->tokens_.back().second = 0; + this->length_ -= this->tokens_.back().second; + this->tokens_.back().second = 0; if ( full ) { this->justify(); @@ -146,3 +148,5 @@ void LineAccumulator::discharge(const bool full) { this->length_ = 0; this->tokens_.clear(); } + +} diff --git a/src/line_accumulator.h b/src/line_accumulator.h index 373cb1b..cb07210 100644 --- a/src/line_accumulator.h +++ b/src/line_accumulator.h @@ -5,6 +5,8 @@ #include <vector> #include <random> +namespace justify { + class LineAccumulator { public: LineAccumulator(const std::uint8_t max_length); @@ -12,7 +14,7 @@ class LineAccumulator { std::uint8_t getMissing() const; - void operator()(const std::string& word); + void operator()(const std::string& token); private: const std::uint8_t max_length_; @@ -30,3 +32,4 @@ class LineAccumulator { }; +} |