//*********************************************************************** int excl(HT& leftExp, const HT& rightExp) { int stPos = -1, curPos = -1, step = 0; if (!rightExp.empty() && !leftExp.empty()) { if (leftExp.size() < rightExp.size()) return 1; int sizeL = leftExp.size(); int sizeR = rightExp.size(); for (int i = 0; i < sizeL && (curPos - stPos + 1) != sizeR; ++i) { for (HT::const_iterator itL = leftExp.cbegin(); itL != leftExp.cend(); ++itL) if (itL->second == i) { if (stPos == -1) { HT::const_iterator itR = rightExp.cbegin(); for (; itR != rightExp.cend() && itR->second != 0; ++itR); if (itR->first == itL->first) curPos = stPos = itL->second; } else for (HT::const_iterator itR = rightExp.cbegin(); itR != rightExp.cend(); ++itR) if (itR->first == itL->first) { if (itL->second > curPos && itL->second - curPos == 1) { curPos = itL->second; } } if ((curPos - stPos +1) == sizeR) break; if (curPos != itL->second) stPos = -1; } } if(stPos!=-1) erase(leftExp, stPos, stPos + rightExp.size()-1); else return 1; } return 0; }
//*********************************************************************** void concat(HT& leftExp, const HT &rightExp) { if (!rightExp.empty()) { int newPos = leftExp.size(); int s = rightExp.size(); for (int i = 0; i < s; ++i) { for (HT::const_iterator it = rightExp.cbegin(); it != rightExp.cend(); ++it) if (it->second == i) { leftExp.insert(HT::value_type((*it).first, newPos++)); break; } } } }
void getInf(const HT& T, char name) { if (!T.empty()) { unsigned n = T.bucket_count(); for (unsigned i = 0; i<n; ++i) { cout << "A[" << i << "]: "; for (auto it = T.cbegin(i); it != T.cend(i); ++it) cout << "{" << it->first << ":" << it->second << "} "; cout << "\n"; } } else cout << "Хеш-таблица " << name << " пустая"; cout << endl; }
//*********************************************************************** void getInfSeq(const HT& T, char name) { if (!T.empty()) { cout << name << " = <"; int s = T.size(); for (int i = 0; i < s; ++i) { for (HT::const_iterator it = T.cbegin(); it != T.cend(); ++it) if (it->second == i) { cout << it->first << ' '; break; } } cout << "\b>" << endl; } else cout << name << " - Пустая последовательность!"<<endl; }