blob: ea813a9c9197bc3c16800e1c1d12f9807f8e9736 (
plain)
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
32
|
#pragma once
#include <string>
#include <vector>
#include "random.h"
class LineAccumulator {
public:
LineAccumulator(const std::size_t max_length);
~LineAccumulator();
void operator()(const std::string& word);
private:
const std::size_t max_length_;
utility::Random random_;
std::size_t length_;
std::vector<std::string> tokens_;
std::vector<std::size_t> spaces_;
void add_token(const std::string& token);
void add_space();
void increase_space_at(const std::size_t index);
void pop_trailing_token();
void discharge(const bool full);
};
|