Pass lines by reference
This commit is contained in:
parent
a565db9b3a
commit
dfa3eabc47
5 changed files with 5 additions and 5 deletions
|
|
@ -21,7 +21,7 @@ public:
|
||||||
std::string regurgitate(int lines=1, std::string start="");
|
std::string regurgitate(int lines=1, std::string start="");
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void swallowLine(std::string line) =0;
|
virtual void swallowLine(std::string& line) =0;
|
||||||
virtual std::string regurgitateLine(std::string start="") =0;
|
virtual std::string regurgitateLine(std::string start="") =0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ MarkovMatrix::~MarkovMatrix()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MarkovMatrix::feed(std::string line)
|
void MarkovMatrix::feed(std::string& line)
|
||||||
{
|
{
|
||||||
for (int i=0; i<=int(line.size()); ++i) {
|
for (int i=0; i<=int(line.size()); ++i) {
|
||||||
int pos = std::max(i-this->length, 0);
|
int pos = std::max(i-this->length, 0);
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ public:
|
||||||
MarkovMatrix(int length);
|
MarkovMatrix(int length);
|
||||||
~MarkovMatrix();
|
~MarkovMatrix();
|
||||||
|
|
||||||
void feed(std::string line);
|
void feed(std::string& line);
|
||||||
void reset(int length=0); // reset the matrix, length>0 -> set a new length
|
void reset(int length=0); // reset the matrix, length>0 -> set a new length
|
||||||
std::map<std::string, int> hiccup(std::string& previous);
|
std::map<std::string, int> hiccup(std::string& previous);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ void SimpleMarkov::throwUp()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SimpleMarkov::swallowLine(std::string line)
|
void SimpleMarkov::swallowLine(std::string& line)
|
||||||
{
|
{
|
||||||
this->matrix.feed(line);
|
this->matrix.feed(line);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ public:
|
||||||
virtual void throwUp(); // empty the belly of previous text
|
virtual void throwUp(); // empty the belly of previous text
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void swallowLine(std::string line);
|
virtual void swallowLine(std::string& line);
|
||||||
virtual std::string regurgitateLine(std::string start="");
|
virtual std::string regurgitateLine(std::string start="");
|
||||||
|
|
||||||
MarkovMatrix matrix;
|
MarkovMatrix matrix;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue