Esempio n. 1
0
void mapOr(const HT& leftExp, const HT& rightExp, HT& result)
{
	result.clear();
	vector<int> vl(leftExp.size()), vr(rightExp.size()), vm;
	transform(leftExp.begin(), leftExp.end(), vl.begin(), keySel);   
	transform(rightExp.begin(), rightExp.end(), vr.begin(), keySel); 
	sort(vl.begin(), vl.end());
	sort(vr.begin(), vr.end());
	set_union(vl.cbegin(), vl.cend(), vr.cbegin(), vr.cend(), inserter(vm, vm.begin()));
	int i=0;
	for (auto it = vm.cbegin(); it != vm.cend(); ++it, ++i)
		result.insert(HT::value_type((*it), i));
}
Esempio n. 2
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;
				}
		}
	}
}
Esempio n. 3
0
//***********************************************************************
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;
}
Esempio n. 4
0
//***********************************************************************
void erase(HT& T, int start, int finish)
{
	if (!T.empty()) {
		int s = T.size();
		for (int i = start; i < s && i <= finish; ++i) {
			for (HT::iterator it = T.begin(); it != T.end(); ++it)
				if (it->second == i) {
					T.erase(it);
					break;
				}
		}
		for (auto &temp : T)
			if (temp.second >= finish)
				temp.second = temp.second - (finish - start) - 1;
	}
}
Esempio n. 5
0
//***********************************************************************
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;
}
Esempio n. 6
0
 /** Get the size of the cache_set.
  *  The size represent the number of non-empty elements that can be
  *  found in the container.
  *  @return the number of elements in the set
  */
 size_type size()         const { return m_ht.size(); }