// Oldham, Jeffrey D. // 2000Apr18 // CS1321 // Program to Find Duplicate URLs // Given a list of URLs, the program finds URLS with duplicate // contents. Every URL with exactly the same contents as another URL // is mentioned as a duplicate. However, we do not guarantee listing // all pairs of duplicates. For example, if three URLs have // exactly the same contents, we will list two, not three pairs. // Command-Line Argument // 1. name of a file containing the names of the URLs #include #include #include #include // has EXIT_SUCCESS #include "hashTable.h" #include "URL.h" int main(int argc, char *argv[]) { if (argc != 2) { cerr << argv[0] << ": file-of-URLs\n"; throw "incorrect number of command-line arguments"; } ifstream URLs(argv[1]); if (!URLs) { cerr << argv[0] << ": " << argv[1] << " not readable\n"; throw "missing URL file"; } hashTable URLTable; string currentURL; while (URLs >> currentURL) { URL u(currentURL); hashTable::insertPair insertAnswer = URLTable.insert(u); if (insertAnswer.first == false) // Found a duplicate. cout << currentURL << " matches " << insertAnswer.second << endl; } URLs.close(); return EXIT_SUCCESS; }