|
@ -32,20 +32,12 @@ void Analyse::backtrack_demo(uint64_t code) { |
|
|
// TODO: confirm code exist
|
|
|
// TODO: confirm code exist
|
|
|
std::cout << cases[code].step << std::endl; |
|
|
std::cout << cases[code].step << std::endl; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::string str("demo"); |
|
|
|
|
|
std::hash<std::string> str_hash; |
|
|
|
|
|
std::cout << "hash str -> " << str_hash(str) << std::endl; |
|
|
|
|
|
|
|
|
|
|
|
int i = 123; |
|
|
|
|
|
std::hash<int> int_hash; |
|
|
|
|
|
std::cout << "hash int -> " << int_hash(i) << std::endl; |
|
|
|
|
|
|
|
|
|
|
|
// std::vector<std::unordered_set<backtrack_t>> dat;
|
|
|
// std::vector<std::unordered_set<backtrack_t>> dat;
|
|
|
|
|
|
|
|
|
auto b_hash = [](const backtrack_t &b) { |
|
|
auto b_hash = [](const backtrack_t &b) { |
|
|
std::cout << "get hash: " << b.code << std::endl; |
|
|
auto hash_dat = std::hash<uint64_t>()(b.code); |
|
|
return (std::size_t)666; |
|
|
std::cout << "get hash: " << b.code << " -> " << hash_dat << std::endl; |
|
|
|
|
|
return hash_dat; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
auto b_eq = [](const backtrack_t &b1, const backtrack_t &b2) { |
|
|
auto b_eq = [](const backtrack_t &b1, const backtrack_t &b2) { |
|
@ -53,29 +45,45 @@ void Analyse::backtrack_demo(uint64_t code) { |
|
|
return b1.code == b2.code; |
|
|
return b1.code == b2.code; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
std::unordered_set<backtrack_t, decltype(b_hash), decltype(b_eq)> test(10, b_hash, b_eq); |
|
|
std::unordered_set<backtrack_t, decltype(b_hash), decltype(b_eq)> test(0, b_hash, b_eq); |
|
|
|
|
|
|
|
|
test.emplace(backtrack_t { |
|
|
// test.emplace(backtrack_t {
|
|
|
.code = 123, |
|
|
// .code = 123,
|
|
|
.layer_num = 0, |
|
|
// .layer_num = 0,
|
|
|
.last = std::list<backtrack_t*>{}, |
|
|
// .last = std::list<backtrack_t*>{},
|
|
|
.next = std::list<backtrack_t*>{}, |
|
|
// .next = std::list<backtrack_t*>{},
|
|
|
}); |
|
|
// });
|
|
|
|
|
|
//
|
|
|
test.emplace(backtrack_t { |
|
|
// test.emplace(backtrack_t {
|
|
|
.code = 233, |
|
|
// .code = 233,
|
|
|
.layer_num = 1, |
|
|
// .layer_num = 1,
|
|
|
.last = std::list<backtrack_t*>{}, |
|
|
// .last = std::list<backtrack_t*>{},
|
|
|
.next = std::list<backtrack_t*>{}, |
|
|
// .next = std::list<backtrack_t*>{},
|
|
|
}); |
|
|
// });
|
|
|
|
|
|
//
|
|
|
test.emplace(backtrack_t { |
|
|
// test.emplace(backtrack_t {
|
|
|
.code = 343, |
|
|
// .code = 343,
|
|
|
.layer_num = 2, |
|
|
// .layer_num = 2,
|
|
|
.last = std::list<backtrack_t*>{}, |
|
|
// .last = std::list<backtrack_t*>{},
|
|
|
.next = std::list<backtrack_t*>{}, |
|
|
// .next = std::list<backtrack_t*>{},
|
|
|
}); |
|
|
// });
|
|
|
|
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < 20; ++i) { |
|
|
|
|
|
test.emplace(backtrack_t { |
|
|
|
|
|
.code = i * 1000, |
|
|
|
|
|
.layer_num = 1, |
|
|
|
|
|
.last = std::list<backtrack_t*>{}, |
|
|
|
|
|
.next = std::list<backtrack_t*>{}, |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
std::cout << "------------------------" << std::endl; |
|
|
|
|
|
std::cout << "hashmap size: " << test.size() << std::endl; |
|
|
|
|
|
std::cout << "bucket count: " << test.bucket_count() << std::endl; |
|
|
|
|
|
std::cout << "load factor: " << test.load_factor() << std::endl; |
|
|
|
|
|
|
|
|
|
|
|
for (uint32_t i = 0; i < test.bucket_count(); ++i) { |
|
|
|
|
|
std::cout << "bucket " << i << " -> " << test.bucket_size(i) << std::endl; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|