-
Notifications
You must be signed in to change notification settings - Fork 12
/
SignificantPattern.cpp
52 lines (41 loc) · 975 Bytes
/
SignificantPattern.cpp
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "SignificantPattern.h"
#include <cassert>
using std::vector;
using std::string;
using std::ostringstream;
SignificantPattern::SignificantPattern()
{
}
SignificantPattern::SignificantPattern(const vector<unsigned int> &sequence)
{
clear();
for(unsigned int i = 0; i < sequence.size(); i++)
push_back(sequence[i]);
}
SignificantPattern::~SignificantPattern()
{
}
unsigned int SignificantPattern::find(unsigned int unit) const
{
for(unsigned int i = 0; i < size(); i++)
if(at(i) == unit)
return i;
assert(false);
}
LexiconUnit* SignificantPattern::makeCopy() const
{
return new SignificantPattern(*this);
}
string SignificantPattern::toString() const
{
ostringstream sout;
sout << "P[";
if(size() > 0)
{
for(unsigned int i = 0; i < size() - 1; i++)
sout << "P" << at(i) << " - ";
if(size() > 0) sout << "P" << back();
}
sout << "]";
return sout.str();
}