HuffmanTree::HuffmanHeap::HuffmanHeap(istream &instr) { // containt all the word of the stream vector<string> allWords; //contain all the word of the stream witouth repeat vector<string> allWordsSingle; char *nextWord = new char[256]; // insert the words in the vectors while(!instr.eof()){ instr.getline(nextWord, 256, ' '); allWords.push_back(nextWord); if(!existInVector(nextWord, allWordsSingle)) { allWordsSingle.push_back(nextWord); } } // insert all the word in the heap for(int i = 0; i < allWordsSingle.size(); i++) { int priority = countInVector(allWordsSingle.at(i), allWords); TreeNode* newTreeNode = new TreeNode(allWordsSingle.at(i)); push(newTreeNode, priority); } }
//add download task, take the URL as identifier bool MyDownload::addDownloadTask(const char* remoteUrl, const char* localFolder) { string remoteUrlString(remoteUrl); string localFolderString(localFolder); if (!existInVector(downloadListRemoteURLs, remoteUrlString)) { downloadListRemoteURLs.push_back(remoteUrlString); downloadListLocalFolders.push_back(localFolderString); return true; } else { return false; } }