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="");
|
||||
|
||||
protected:
|
||||
virtual void swallowLine(std::string line) =0;
|
||||
virtual void swallowLine(std::string& line) =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) {
|
||||
int pos = std::max(i-this->length, 0);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ public:
|
|||
MarkovMatrix(int length);
|
||||
~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
|
||||
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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ public:
|
|||
virtual void throwUp(); // empty the belly of previous text
|
||||
|
||||
private:
|
||||
virtual void swallowLine(std::string line);
|
||||
virtual void swallowLine(std::string& line);
|
||||
virtual std::string regurgitateLine(std::string start="");
|
||||
|
||||
MarkovMatrix matrix;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue