-
Notifications
You must be signed in to change notification settings - Fork 0
/
filter.h
49 lines (42 loc) · 1.25 KB
/
filter.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#ifndef FILTER_H
#define FILTER_H
#include <vector>
#include <string>
#include <map>
#include <iostream>
#include <algorithm>
using namespace std;
template <typename T,typename... Arguments>
auto filter(const vector<T>&ip_pool,Arguments... args){
T vec={to_string(args)...};
vector<T>vec_ip;
multimap<T,T>multimap_ip;
for(auto el:ip_pool){
T str_vec;
for(int i=0;i<sizeof...(args);i++){
str_vec.push_back(el.at(i));
}
multimap_ip.insert(pair<T,T>(str_vec,el));
}
auto ret = multimap_ip.equal_range(vec);
for(auto it=ret.first;it!=ret.second;++it){
vec_ip.emplace_back(it->second);
}
return vec_ip;
}
auto compare = [](const void *a, const void *b)->int
{
std::vector<std::string>_a=*(std::vector<std::string>*)a;
std::vector<std::string>_b=*(std::vector<std::string>*)b;
for(size_t i=0;i<_a.size();i++){
if(atoi(_a.at(i).c_str())>atoi(_b.at(i).c_str()))
return true;
else if(atoi(_a.at(i).c_str())==atoi(_b.at(i).c_str()))
continue;
else
return false;
}
};
vector<vector<string>> filter_any(const vector<vector<string>>&ip_pool, int find_byte);
void printv(vector<vector<string>>&ip_pool);
#endif // FILTER_H