本文整理汇总了C++中Updater::get_similar方法的典型用法代码示例。如果您正苦于以下问题:C++ Updater::get_similar方法的具体用法?C++ Updater::get_similar怎么用?C++ Updater::get_similar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Updater
的用法示例。
在下文中一共展示了Updater::get_similar方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
bool Filemanager::update(std::string file_path) {
Updater *updater = new Updater();
std::pair<std::map<int, int>, std::vector<std::pair<long, long> > > updater_result = updater->get_similar(file_path);
std::map<int, int> similar_chunk = updater_result.first;
std::vector<std::pair<long, long> > diff = updater_result.second;
// std::cout << "similar:" << std::endl;
// updater->show_similar(similar_chunk);
// std::cout << "diff bytes:" << std::endl;
updater->show_diff(diff);
this->mworker = new Metaworker();
this->mworker->load(file_path);
std::vector<int> chunk_to_del;
this->mworker->show();
for(int i = 0; i < mworker->mdata_size(); i++) {
if(similar_chunk.find(i) == similar_chunk.end()) {
// std::cout << i << " ";
chunk_to_del.push_back(i);
} else {
mworker->mdata[i].start += ( *(similar_chunk.find(i))).second - 1;
mworker->mdata[i].finish += ( *(similar_chunk.find(i))).second - 1;
}
}
// std::cout << std::endl << "old mdata: " << std::endl;;
for(int i = chunk_to_del.size() - 1;i >= 0; i--) {
// std::cout << "num: " << i << " chunk:" << chunk_to_del[i] << std::endl;
this->rm_file(this->mworker->get(chunk_to_del[i]).cipher_hash);
this->mworker->remove(chunk_to_del[i]);
}
for(int i = 0; i < diff.size(); i++) {
this->segmentate(file_path, diff[i].first, diff[i].second);
}
std::cout << std::endl << "new mdata: " << std::endl;
this->mworker->sort();
this->mworker->save();
// this->mworker->save();
return true;
}