int main(int argc, const char *argv[]) {

	IOUtils io;
	io.openStream(argc,argv);
	std::string input, encrypted, decrypted;
	input = io.readFromStream();
	std::cout << "Original text:" << std::endl << input;

	// 2. Test various ciphers

	// Simple ROT13 cipher
	Rot13Cipher rot13;
	encrypted = rot13.encrypt(input);
	std::cout << "Encrypted text:" << std::endl << encrypted;

	decrypted = rot13.decrypt(encrypted);
	std::cout << "Decrypted text:" << std::endl << decrypted;

	if (decrypted == input) std::cout << "Decrypted text matches input!" << std::endl;
	else {
		std::cout << "Oops! Decrypted text doesn't match input!" << std::endl;
		return 1;   // Make sure to return a non-zero value to indicate failure
	}

	return 0;
}
int main(int argc, const char *argv[]) {
	using namespace std;

	mr::SentenceStats sentenceStats;
	std::map<string,int> final;

	IOUtils io;
	io.openStream(argc,argv);
	vector<string> fileNames = io.split(io.readFromStream(),'\n');
	io.closeStream();
	// start timer
	auto start = std::chrono::steady_clock::now();

#ifndef PARALLEL_MR
	// Invoke the Map Reduce runtime
	mr::run(sentenceStats, fileNames, final);
#else	
	
	mr::prun<string,int>(sentenceStats, fileNames, final, 10, 4);
#endif

	auto end = std::chrono::steady_clock::now();
		
	auto diff = end - start;
	
	cout << "MapReduce time: " << std::chrono::duration <double, std::milli> (diff).count() << " ms" << endl;
	return 0;
}
Пример #3
0
int main(int argc, const char *argv[]) {
	using namespace std;

	mr::SentenceStats sentenceStats;
	std::map<string,int> final;

	IOUtils io;
	io.openStream(argc,argv);
	vector<string> fileNames = io.split(io.readFromStream(),'\n');
	io.closeStream();

	auto start = std::chrono::steady_clock::now(); // start timer

#ifndef PARALLEL_MR
	// Invoke the Map Reduce runtime
	mr::run(sentenceStats, fileNames, final);
#else	
	// To run the parallel Map Reduce, include -DPARALLEL_MR to 
	// the CXXFLAGS variable in the Makefile,
	// then make clean and make
	mr::prun<string,int>(sentenceStats, fileNames, final, 10, 4);
#endif

	auto end = std::chrono::steady_clock::now();

	// Print the final results
	for (auto it = final.begin(); it != final.end(); it++ )
		cout << it->first << ": " << it->second << endl;

	auto diff = end - start;
	cout << "MapReduce time: " << std::chrono::duration <double, std::milli> (diff).count() << " ms" << endl;
	return 0;
}
Пример #4
0
int main(int argc, const char *argv[]) {

	IOUtils io;
	io.openStream(argc,argv);
	std::string input, encrypted, decrypted;
	input = io.readFromStream();
	std::cout << "Original text:" << std::endl << input;

	CaesarCipher caesar;
	encrypted = caesar.encrypt(input);
	std::cout << "Encrypted text:" << std::endl << encrypted;

	decrypted = caesar.decrypt(encrypted);
	std::cout << "Decrypted text:" << std::endl << decrypted;

	if (decrypted == input) std::cout << "Decrypted text matches input!" << std::endl;
	else {
		std::cout << "Oops! Decrypted text doesn't match input!" << std::endl;
		return 1; 
	}

	return 0;
}
Пример #5
0
int main(int argc, const char *argv[]) {
	using namespace std;

	// Use MapReduce to compute a word count
	mr::WordCount wordCount;
	std::map<string,int> final;

	// Assume that the URLs to process are listed (one per line)
	// a file called wordCount-input.txt in the current directory
	IOUtils io;
	io.openStream(argc,argv);
	vector<string> fileNames = io.split(io.readFromStream(),'\n');
	io.closeStream();

	auto start = std::chrono::steady_clock::now(); // start timer

#ifndef PARALLEL_MR
	// Invoke the Map Reduce runtime
	mr::run(wordCount, fileNames, final);
#else	
	// To run the parallel Map Reduce, include -DPARALLEL_MR to 
	// the CXXFLAGS variable in the Makefile,
	// then make clean and make
	mr::prun<string,int>(wordCount, fileNames, final, 10, 4);
#endif

	auto end = std::chrono::steady_clock::now();

	// Print the final results
	for (auto it = final.begin(); it != final.end(); it++ )
		cout << it->first << ": " << it->second << endl;

	auto diff = end - start;
	cout << "MapReduce time: " << std::chrono::duration <double, std::milli> (diff).count() << " ms" << endl;
	return 0;
}