コード例 #1
0
ファイル: DoubleList.cpp プロジェクト: miracle2k/mp3diags
void DoubleList::initAvailable()
{
    m_listPainter.m_vAvailable.clear();

    switch (m_eSelectionMode)
    {
    case MULTIPLE:
        for (int i = 0, n = cSize(m_listPainter.getAll()); i < n; ++i)
        {
            m_listPainter.m_vAvailable.push_back(i); // in a sense, m_listPainter.m_vAvailable shouldn't be used at all in this case, and it isn't in the DoubleList code; however, it makes AvailableModel easier, because while DoubleList always has to check the value of m_eSelectionMode anyway, AvailableModel doesn't have to do this, but an empty m_listPainter.m_vAvailable in the MULTIPLE case would force it to do so;
        }
        break;

    case SINGLE_UNSORTABLE:
        {
            int n (cSize(m_listPainter.getAll()));
            m_listPainter.m_vSel.push_back(n);
            for (int i = 0, j = 0; i < n; ++i)
            {
                if (i < m_listPainter.m_vSel[j])
                {
                    m_listPainter.m_vAvailable.push_back(i);
                }
                else
                {
                    ++j;
                }
            }
            m_listPainter.m_vSel.pop_back();
        }
        break;

    case SINGLE_SORTABLE:
        {
            SubList v (m_listPainter.m_vSel.begin(), m_listPainter.m_vSel.end());
            sort(v.begin(), v.end());
            int n (cSize(m_listPainter.getAll()));
            v.push_back(n);
            for (int i = 0, j = 0; i < n; ++i)
            {
                if (i < v[j])
                {
                    m_listPainter.m_vAvailable.push_back(i);
                }
                else
                {
                    ++j;
                }
            }
        }
        break;

    }
}
コード例 #2
0
ファイル: BitList.cpp プロジェクト: ForTheBetter/pubsub
void build_subIndex_from_subList(SubIndex &subIndex, SubList &subList, vector<pair<int, int> > &attrList)
{
	int maxsz = ORDER_BY_SIZE ? SUB_SIZE_UB : 1;
	for(int sz = 0; sz < maxsz; sz++){
		for(int i = 0; i < (int)attrList.size(); i++){
			for(int j = 0; j <= attrList[i].second; j++){
				int wordId;
				if(attrList[i].second > MAGNITUDE){
					wordId = attrList[i].first + j / ((int) ceil(1.0 * attrList[i].second / MAGNITUDE));
				}
				else{
					wordId = attrList[i].first + j;
				}
				subIndex[sz][wordId].wordId = subIndex[sz][wordId].rowId = wordId;
			}
		}
	}
    for(SubList::iterator sit = subList.begin(); sit != subList.end(); ++sit){
		int sz = sit->attrCnt;
		if(!ORDER_BY_SIZE){
			sz = 1;
		}
		for(vector<AttrRange>::iterator ait = sit->attrList.begin(); ait != sit->attrList.end(); ++ait){
			int attrId = ait->attrId;
            for(vector<Interval>::iterator iit = ait->intervalList.begin(); iit != ait->intervalList.end(); ++iit){
				for(int val = iit->left; val <= iit->right; val++){
					int wordId;
					if(attrList[attrId].second > MAGNITUDE){
						wordId = attrList[attrId].first + val / ((int) ceil(1.0 * attrList[attrId].second / MAGNITUDE));
					}
					else{
						wordId = attrList[attrId].first + val;
					}
					BitNumber newNumber;
                    newNumber.did = sit->subId; newNumber.eid = 1;
                    newNumber.weight = 1; newNumber.colId = sit->subId;
                    subIndex[sz - 1][wordId].bitList.push_back(newNumber);
				}
            }
        }
    }
}