当前位置:网站首页>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));
```
边栏推荐
- Docker compose configuration mysql, redis, mongodb
- The second composition template of postgraduate entrance examination English / chart composition, English chart composition is enough
- Deep copy event bus
- 2.7 binary tree, post order traversal - [FBI tree]
- JS6day(DOM结点的查找、增加、删除。实例化时间,时间戳,时间戳的案例,重绘和回流)
- OpenCV中cv2.VideoWriter_fourcc()函数和cv2.VideoWriter()函数的结合使用
- Lombok common annotations
- [I'm a mound pytorch tutorial] learning notes
- Why do programmers have the idea that code can run without moving? Is it poisonous? Or what?
- Go learning notes - multithreading
猜你喜欢

Why do programmers have the idea that code can run without moving? Is it poisonous? Or what?

Sweetheart leader: Wang Xinling

Multiply LCA (nearest common ancestor)

Discrimination of the interval of dichotomy question brushing record (Luogu question sheet)

趣味 面试题

深拷貝 事件總線
![1380. Lucky numbers in the matrix [two-dimensional array, matrix]](/img/8c/c050af5672268bc7e0df3250f7ff1d.jpg)
1380. Lucky numbers in the matrix [two-dimensional array, matrix]
![[old horse of industrial control] detailed explanation of Siemens PLC TCP protocol](/img/13/9002244555ebe8a61660c2506993fa.png)
[old horse of industrial control] detailed explanation of Siemens PLC TCP protocol
![2.6 using recursion and stack - [tower of Hanoi problem]](/img/fc/45038170dafd104691c93716b103cf.jpg)
2.6 using recursion and stack - [tower of Hanoi problem]

浏览器存储方案
随机推荐
Rust search server, rust quick service finding tutorial
线性DP AcWing 897. 最长公共子序列
Enhance network security of kubernetes with cilium
JDBC 预防sql注入问题与解决方法[PreparedStatement]
When uploading a file, the server reports an error: iofileuploadexception: processing of multipart / form data request failed There is no space on the device
String palindrome hash template question o (1) judge whether the string is palindrome
LeetCode—剑指 Offer 59 - I、59 - II
Shutter encapsulated button
Go学习笔记—基于Go的进程间通信
浏览器存储方案
In development, why do you find someone who is paid more than you but doesn't write any code?
Embedded Software Engineer career planning
"As a junior college student, I found out how difficult it is to counter attack after graduation."
JS8day(滚动事件(scroll家族),offset家族,client家族,轮播图案例(待做))
Leetcode - Sword finger offer 37, 38
drools执行指定的规则
Fastdateformat why thread safe
Find the common ancestor of any two numbers in a binary tree
LeetCode—剑指 Offer 37、38
[old horse of industrial control] detailed explanation of Siemens PLC TCP protocol