当前位置:网站首页>std::vector批量导入快速去重方法
std::vector批量导入快速去重方法
2022-07-02 09:45:00 【如鹿渴慕泉水】
目的数组std::vector searchapp
inline bool has_scan_impl(const stSWLIST& app1, const stSWLIST& app2)
{
bool cond = app1.path == app2.path;
return cond;
}
const std::string fl =filename
std::ifstream ifs(fl, ios_base::in);
if (ifs.is_open())
{
std::string retbuf;
std::copy(std::istreambuf_iterator<char>{ifs}, std::istreambuf_iterator<char>{},
std::back_inserter(retbuf));
ifs.close();
cJSON* lpNode = cJSON_Parse(retbuf.c_str());
int iSize = cJSON_GetArraySize(lpNode);
std::vector<stSWLIST> searchapp2;
for (int index = 0; index < iSize; index++)
{
cJSON* lpArayNode = cJSON_GetArrayItem(lpNode, index);
stSWLIST filedump = json2app(lpArayNode);
searchapp2.push_back(filedump);
//这个太慢不用了
/*if (add_scan(filedump)) {
continue;
}*/
}
std::vector<stSWLIST> searchappdel;
std::copy(std::find_if(searchapp.begin(), searchapp.end(), [searchapp2](const stSWLIST& app1)
{
return std::find_if(searchapp2.begin(), searchapp2.end(), [app1](const stSWLIST& app2)
{
return has_scan_impl(app1, app2);
}) != searchapp2.end();
}) , searchapp.end(),std::back_inserter(searchappdel));
searchapp.erase(std::remove_if(searchapp.begin(), searchapp.end(), [searchappdel](const stSWLIST& app1)
{
return std::find_if(searchappdel.begin(), searchappdel.end(), [app1](const stSWLIST& app2)
{
return has_scan_impl(app1, app2);
}) != searchappdel.end();
}), searchapp.end());
std::copy(searchapp2.begin(), searchapp2.end(), std::back_inserter(searchapp));
```
边栏推荐
- Map and set
- Fluent fluent library encapsulation
- 8 examples of using date commands
- How to write a pleasing English mathematical paper
- Deep Copy Event bus
- Shuttle encapsulated AppBar
- [ybtoj advanced training guidance] judgment overflow [error]
- ASP. Net MVC default configuration, if any, jumps to the corresponding program in the specified area
- drools动态增加、修改、删除规则
- VLAN experiment
猜你喜欢
Lekao: 22 year first-class fire engineer "technical practice" knowledge points
2.6 using recursion and stack - [tower of Hanoi problem]
JSON序列化 与 解析
Is the neural network (pinn) with embedded physical knowledge a pit?
线性DP AcWing 895. 最长上升子序列
Drools dynamically add, modify, and delete rules
arcgis js 4.x 地图中加入图片
Rust search server, rust quick service finding tutorial
Anti shake throttle
Programmers can't find jobs after the age of 35? After reading this article, you may be able to find the answer
随机推荐
Sub thread get request
Anxiety of a 211 programmer: working for 3 years with a monthly salary of less than 30000, worried about being replaced by fresh students
"As a junior college student, I found out how difficult it is to counter attack after graduation."
Anti shake throttle
Shuttle encapsulated AppBar
深拷貝 事件總線
分布式机器学习框架与高维实时推荐系统
JS8day(滚动事件(scroll家族),offset家族,client家族,轮播图案例(待做))
LeetCode—剑指 Offer 37、38
What data types does redis have and their application scenarios
Dijkstra AcWing 850. Dijkstra求最短路 II
Drools executes the specified rule
js 迭代器 生成器 异步代码处理 promise+生成器 -> await/async
Introduction to CPU instruction set
2.6 using recursion and stack - [tower of Hanoi problem]
AI中台技术调研
线性DP AcWing 895. 最长上升子序列
LeetCode—剑指 Offer 51. 数组中的逆序对
Floyd AcWing 854. Floyd求最短路
Redis bloom filter