diff options
author | Adrian Kummerlaender | 2016-04-02 21:51:57 +0200 |
---|---|---|
committer | Adrian Kummerlaender | 2016-04-02 21:51:57 +0200 |
commit | a5a81425f4e656ecf0e867e114863b1b208e90b0 (patch) | |
tree | 364b7ef1bb640c87f3f8cbb7547754ed7f28434d /src | |
parent | 59bfdf3b83119c9e5e29f94362307b7e8a3df43a (diff) | |
download | justify-a5a81425f4e656ecf0e867e114863b1b208e90b0.tar justify-a5a81425f4e656ecf0e867e114863b1b208e90b0.tar.gz justify-a5a81425f4e656ecf0e867e114863b1b208e90b0.tar.bz2 justify-a5a81425f4e656ecf0e867e114863b1b208e90b0.tar.lz justify-a5a81425f4e656ecf0e867e114863b1b208e90b0.tar.xz justify-a5a81425f4e656ecf0e867e114863b1b208e90b0.tar.zst justify-a5a81425f4e656ecf0e867e114863b1b208e90b0.zip |
Move `LineAccumulator` closure into `justify` project namespace
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 { }; +} |