Skip to content
Snippets Groups Projects
Commit 96e1e7d1 authored by Nicholas Yang's avatar Nicholas Yang
Browse files

quick program that checks for unique ids in the files

parent 6d1b759a
No related branches found
No related tags found
No related merge requests found
......@@ -9,11 +9,8 @@ Indexer::Indexer() {
void Indexer::run() {
while(pointerToDictionaries.Size() != 0) {
if(totalIndexed > 50000) {
save();
reset();
totalIndexed = 0;
}
save();
reset();
unordered_map<string, vector<int>>* dictionary = pointerToDictionaries.Pop();
for(auto word : *dictionary) {
indexedCount += word.second.size();
......@@ -23,6 +20,7 @@ void Indexer::run() {
}
}
currentlyIndexed += indexedCount;
indexedCount = 0;
}
save();
}
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
#include <iostream>
#include <fstream>
#include <vector>
#include <unordered_map>
using namespace std;
bool isNumber(string line) {
return (atoi(line.c_str()));
}
const int NUMBER_OF_FILES = 5;
int main() {
vector <ifstream> files;
string word;
unordered_map <int, bool> wow;
for(int i = 0; i < NUMBER_OF_FILES; i++) {
string file = "index" + to_string(i) + ".txt";
files.push_back(ifstream(file));
}
for(int j = 0; j < files.size(); j++) {
while(files[j] >> word) {
if(isNumber(word)) {
int ss = stoi(word);
if(wow[ss]) {
cout << " U FAILED " << endl;
cout << ss << " APPEARED MULTIPLE TIMES!!!" << endl;
exit(999);
} else {
wow[ss] = true;
}
}
}
}
cout << wow.size() << endl;
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment