Я пытаюсь выполнить итерацию по одному вектору (используя два итератора), чтобы удалить элементы, которые являются подмножествами или копиями других элементов (векторы есть). То, что у меня ниже, компилируется, но выполнение программы останавливается раньше (не все подмножества или копии удаляются). Я прочитал строки из файла и поместил их в векторы: sequence_1 и sequence_2. Любая помощь будет очень высоко ценится.Итерация через единый вектор и удаление элементов, которые являются подмножествами других элементов?
int c,j; string first_sequence, second_sequence;
vector<string>::iterator ivector1; vector<string>::iterator ivector2;
vector<string>::iterator ishort;
// all relevant headers to the material are included in original code
//comparison of vector elements
size_t location,x,y,k,s;
k = sequence_1.size();
s = sequence_2.size();
for(ivector1 = sequence_1.begin(); ivector1< sequence_1.end(); ++ivector1){
for(ivector2= sequence_1.begin()+1;ivector2<sequence_1.end(); ++ivector2){
first_sequence = *ivector1; second_sequence = *ivector2;
if(*ivector1 == *ivector2){
cout << "Deleting the sequence with id: <" << endl << *ivector2 << endl;
sequence_1.erase(remove(ivector2,sequence_1.end(),*ivector2),sequence_1.end());
} else if(*ivector1 != *ivector2){
x = first_sequence.size();
y = second_sequence.size();
if(x > y){
location = first_sequence.find(second_sequence);
if (location != -1){
cout << "Deleting the sequence with id: <"<< endl << *ivector2 << endl;
sequence_1.erase(remove(ivector2,sequence_1.end(),*ivector2),sequence_1.end());
}
} else if (y > x) {
location = second_sequence.find(first_sequence);
if (location != -1){
cout << "Deleting the sequence with id: <"<< *ivector1 << endl;
sequence_1.erase(remove(sequence_1.begin(),ivector1+1,*ivector1),sequence_1.end());
}
}
}
}
}