Ejemplo n.º 1
0
void SymbolList::updateDirtyVectors() const
{
	if (!m_vectors_dirty)
		return;
	
	m_name_order.clear();
	m_addr_order.clear();
	
	
	m_addr_order.reserve(m_name_lookup.size());
	// Populate vectors
	for (symnamemap_ci i = m_name_lookup.begin(); i != m_name_lookup.end(); i++)
	{
		m_addr_order.push_back((*i).second);
	}
	
	m_name_order.reserve(m_addr_order.size());
	for (symnamemap_ci i = m_name_lookup.begin(); i != m_name_lookup.end(); i++)
	{
		m_name_order.push_back((*i).second);
	}
	/*
	std::copy(m_addr_order.begin(), m_addr_order.end(), m_name_order.begin());
	*/
	// Sort vectors
	std::sort(m_addr_order.begin(), m_addr_order.end(), addrSort());
	std::sort(m_name_order.begin(), m_name_order.end(), nameSort());
	
	m_vectors_dirty = false;
}
Ejemplo n.º 2
0
void runProgram(int &op)
{
	string dFileLine;
	vector<string> dParsedLine;
	vector<Donations> donors;
	string selectDonor;

	// Open input and output files
	ifstream fin;
	ofstream fout;
	openFiles(fin, fout);

	while(!fin.eof())
		// Read a line from the file and push onto end of array
			donors.push_back(readFile(dFileLine, dParsedLine, fin));
	

	switch (op)
		{
			case 0: cout << "Closing program." << endl; exit(0);
			case 1: nameSort(donors); break;
			case 2: donorSortAsc(donors); break;
			case 3: donorSortDes(donors); break;
			case 4: categorySortAsc(donors); break;
			case 5: idSortAsc(donors); break;
			case 6: donorSortOneDonorByValue(donors); break;
			default: cout << "Invalid option, please try again." << endl;  system("PAUSE"); system("CLS"); break;
		}

	int dArraySize = donors.size();
	for(int i = 0; i < dArraySize; i++)
		writeFile(donors[i], fout);
	
	// Write report summary
	createReportSummary(donors, fout);

}