vector<string> compactRepresent(){
bool matched = false;
string dif = "";
string currentDif = "";
vector <string> text;
unsigned int i, j;
for (i = 0; i < vec[0].size(); ++i)
{
for (j = 1; j < vec.size(); ++j)
{
if (vec[0][i] != vec[j][i])
{
if (find(currentDif.begin(), currentDif.end(), vec[0][i]) == currentDif.end())
{
currentDif += vec[0][i];
}
if (find(currentDif.begin(), currentDif.end(), vec[j][i]) == currentDif.end())
{
currentDif += vec[j][i];
}
matched = true;
}
}
if (matched)
{
dif += " {" + currentDif + "} ";
currentDif = "";
text.push_back(dif);
matched = false;
}
else
{
dif += vec[0][i];
currentDif = "";
text.push_back(dif);
matched = false;
}
}
cout << dif << endl;
return text;
}
int match (vector<string> patterns){
vector<string> allSegment = compactRepresent();
vector<int> matchLists;
for(string smallPatt : patterns)
{
EDSM edsm(smallPatt);
for(vector<string> segments: allSegment)
{
edsm.searchNextSegment(segments);
edsm.getMatches();
}
matchLists = edsm.getMatches();
}
for(const int m: matchLists)
{
cout << m << endl;
}
return 0;
}
첫번째 방법 compactRepresent 컴팩트 방식으로 다수의 시퀀스를 나타낸다위한 내부 벡터 및 상기 두번째 매치 들어, 어떤 방법을 사용하여 일치를 찾기 위해 시도한다. 변환은 각 루프
error: conversion from ‘std::__cxx11::basic_string<char>’ to non-scalar type ‘std::vector<std::__cxx11::basic_string<char> >’ requested
for(vector<string> segments: allSegment)
감사합니다 : 나는 철저한 allsegments 각 세그먼트를 반복하고 때 내 질문은
, 그것은 다음과 같은 데이터 유형 오류를 제공합니다. 이 변수 정의를 감안할 때
가'(벡터 세그먼트 : allSegment)에 대한 안 :''(allSegment 문자열 세그먼트)에 대한'이 될 오직 당신이해야 할 때 복사, 각 문자열에 '을'Vector ' 요소를 포함하고있는 것처럼 열거하려고합니다. 이는 의미가 없습니다. –
cdhowie
const
참조를 복용 생각해? 당신은'vector'문자열'을'벡터'으로 변환 할 수 없다는 오류가 발생했습니다. –
chris
그 효과가 :하지만 벡터 유형을 필요로 _segments_, 나는 'edsm.searchNextSegments (세그먼트)'벡터 형식을 사용하는 함수로 전달하기 때문에 필요합니다. @cdhowie – Shukri