YOLOv5行人检测实战:3000张数据微调、推理与RK3568量化部署
2026/10/11 22:16:09
参考⽂档
template < class Key, // unordered_set::key_type/value_type class Hash = hash<Key>, // unordered_set::hasher class Pred = equal_to<Key>, // unordered_set::key_equal class Alloc = allocator<Key> // unordered_set::allocator_type > class unordered_set;pair<iterator,bool> insert ( const value_type& val ); size_type erase ( const key_type& k ); iterator find ( const key_type& k );#include<unordered_set> #include<unordered_map> #include<set> #include<iostream> using namespace std; void test_set1() { set<int> s; s.insert(3); s.insert(1); s.insert(5); s.insert(7); for (auto e : s) { cout << e << " "; } cout << endl; unordered_set<int> us; us.insert(3); us.insert(1); us.insert(5); us.insert(7); for (auto e : us) { cout << e << " "; } cout << endl; } int test_set2() { const size_t N = 1000000; unordered_set<int> us; set<int> s; vector<int> v; v.reserve(N); srand(time(0)); for (size_t i = 0; i < N; ++i) { //v.push_back(rand()); // N⽐较⼤时,重复值⽐较多 v.push_back(rand()+i); // 重复值相对少 //v.push_back(i); // 没有重复,有序 } size_t begin1 = clock(); for (auto e : v) { s.insert(e); } size_t end1 = clock(); cout << "set insert:" << end1 - begin1 << endl; size_t begin2 = clock(); us.reserve(N); for (auto e : v) { us.insert(e); } size_t end2 = clock(); cout << "unordered_set insert:" << end2 - begin2 << endl; int m1 = 0; size_t begin3 = clock(); for (auto e : v) { auto ret = s.find(e); if (ret != s.end()) { ++m1; } } size_t end3 = clock(); cout << "set find:" << end3 - begin3 << "->" << m1 << endl; int m2 = 0; size_t begin4 = clock(); for (auto e : v) { auto ret = us.find(e); if (ret != us.end()) { ++m2; } } size_t end4 = clock(); cout << "unorered_set find:" << end4 - begin4 << "->" << m2 << endl; cout << "插⼊数据个数:" << s.size() << endl; cout << "插⼊数据个数:" << us.size() << endl << endl; size_t begin5 = clock(); for (auto e : v) { s.erase(e); } size_t end5 = clock(); cout << "set erase:" << end5 - begin5 << endl; size_t begin6 = clock(); for (auto e : v) { us.erase(e); } size_t end6 = clock(); cout << "unordered_set erase:" << end6 - begin6 << endl << endl; return 0; } int main() { test_set2(); return 0; }pair<iterator,bool> insert ( const value_type& val ); size_type erase ( const key_type& k ); iterator find ( const key_type& k ); mapped_type& operator[] ( const key_type& k );Buckets和Hash policy系列的接⼝分别是跟哈希桶和负载因⼦相关的接⼝