コード例 #1
0
/**
 * @brief process Manipulates columns by adding the contents of thie record.
 *
 * Implematations should examine columns to determine the record history.
 */
void VeryLongStringRecord::process(SPSSImporter* importer, SPSSImportDataSet *dataset)
{
	SPSSImportDataSet::LongColsData strLengths;

	{
		Tuples strLens = breakNamePairs(_string_lengths);
		for (Tuples::const_iterator i = strLens.begin(); i != strLens.end(); i++)
			strLengths.insert(pair<string, size_t>(i->first, atol(i->second.c_str())));
	}
	dataset->veryLongColsDat(strLengths);

#ifdef JASP_DEBUG
//	DEBUG_COUT3("Found ", strLengths.size(), " tuples:");
//	for (map<string, size_t>::const_iterator i = strLengths.begin(); i != strLengths.end(); i++)
//	{
//		DEBUG_COUT5("... name = \"", i->first, "\" value = ", i->second, ".");
//	}
#endif

}
コード例 #2
0
ファイル: ProgressiveTopk.cpp プロジェクト: andyhehk/why-not
void PreComputeTA(char * filename, vector<vector<Cell> >& storebyrow, map<int, vector<float> >& index)
{
	Tuples allTuples;
	
	ReadData(filename, allTuples);

    int dimension;
    cout<<"Input Dimension:"<<endl;
    scanf("%d", &dimension);

	vector<list<Cell> >  sortedTuples(dimension);

    int position[5] = {0,1,2, 3, 4};

	for(Tuples::iterator iter = allTuples.begin(); iter!=allTuples.end(); iter++)
	{
		Tuple tuple = *iter;
		vector<float> needed_attr;
		
		for(int i=0; i<dimension; i++)
		{
			Cell temp;
			temp.ID = tuple.ID;
			try{
				temp.data = tuple.data.at(position[i]);
				needed_attr.push_back(temp.data);
				sortedTuples.at(i).push_back(temp);
			}
			catch(out_of_range outOfRange)
			{
				cout << "\n\nException1: "<<outOfRange.what()<<endl;
				cout<< tuple.data.size()<<","<<tuple.ID;
				return;
			}
		}

		index.insert(pair<int, vector<float> >(tuple.ID, needed_attr));
	}


	for(vector<list<Cell> >::iterator iter = sortedTuples.begin(); iter!=sortedTuples.end(); iter++)
	{
		(*iter).sort(compfn);

		list<Cell>  temp = *iter;

		if(storebyrow.empty())
		{
			for(list<Cell>::iterator iter1 = temp.begin(); iter1!=temp.end();iter1++)
			{
				vector<Cell> tempvector;
				Cell tempCell;

				tempCell.ID = iter1->ID;
				tempCell.data = iter1->data;

				tempvector.push_back(tempCell);

				storebyrow.push_back(tempvector);	
			}
		}

		else
		{
			unsigned int i = 0;
			for(list<Cell>::iterator iter1 = temp.begin(); iter1!=temp.end();iter1++, i++)
			{
				Cell tempCell;

				tempCell.ID = iter1->ID;
				tempCell.data = iter1->data;

				storebyrow[i].push_back(tempCell);
			}

			assert(i == temp.size());
		}
	}	


}