Browse Source

update: range index statistics

master
Dnomd343 2 years ago
parent
commit
2268edc623
  1. 87
      all_cases/short_code.cc

87
all_cases/short_code.cc

@ -57,9 +57,8 @@ uint32_t code_from_string(const std::string &short_code) {
int main() {
auto a = AllCases();
a.find_all_cases();
// a.find_all_cases();
//
// std::vector<uint64_t> all_cases;
// for (int n = 0; n < 16; ++n) {
// uint64_t prefix = (uint64_t)n << 32;
@ -73,7 +72,7 @@ int main() {
// all_cases_dict[all_cases[i]] = i;
// }
uint32_t short_code = 14323231;
// uint32_t short_code = 14323231;
// printf("%09lX\n", all_cases[0]);
// printf("%09lX\n", all_cases[short_code]);
// printf("%09lX\n", all_cases[ALL_CASES_NUMBER - 1]);
@ -86,27 +85,71 @@ int main() {
// 0 <= short_code < ALL_CASES_NUMBER
// uint32_t short_code = 5203298;
int head = 0;
for (; head < 16; ++head) {
if (short_code < ALL_CASES_SIZE[head]) {
break;
}
short_code -= ALL_CASES_SIZE[head];
}
std::cout << "head: " << head << std::endl;
std::cout << "sub short code: " << short_code << std::endl;
int index = 0;
for (auto &range : a.basic_ranges) {
if (AllCases::check_case(head, range)) {
if (index == short_code) {
printf("%08X\n", AllCases::binary_reverse(range));
break;
}
++index;
}
// int head = 0;
// for (; head < 16; ++head) {
// if (short_code < ALL_CASES_SIZE[head]) {
// break;
// }
// short_code -= ALL_CASES_SIZE[head];
// }
// std::cout << "head: " << head << std::endl;
// std::cout << "sub short code: " << short_code << std::endl;
//
// int index = 0;
// for (auto &range : a.basic_ranges) {
// if (AllCases::check_case(head, range)) {
// if (index == short_code) {
// printf("%08X\n", AllCases::binary_reverse(range));
// break;
// }
// ++index;
// }
// }
// group size => 256 => 8-bits
// min range -> xx * 7 -> 14-bits
// 00 00 00 00 ... => ... 00 00 00 00
// 00 00 00 01 ... => ... 01 00 00 00
// 00 00 00 10 ... => ... 10 00 00 00
// 00 00 00 11 ... => ... 11 00 00 00
// ...
// ...00000000 -> 0
// ...01000000 -> ...
// ...10000000 -> ...
// ...11000000 -> ...
// record start search point
std::cout << a.all_cases[6].size() << std::endl;
// printf("%08X\n", a.all_cases[6][0]);
// printf("%08X\n", a.all_cases[6][1]);
// printf("%08X\n", a.all_cases[6][2]);
uint32_t index[256] = {0};
for (auto &range : a.all_cases[6]) {
++index[range >> 24];
}
std::cout << "00: " << index[0x00] << std::endl;
std::cout << "01: " << index[0x01] << std::endl;
std::cout << "7D: " << index[0x7D] << std::endl;
std::cout << "7E: " << index[0x7E] << std::endl;
std::cout << "7F: " << index[0x7F] << std::endl;
std::cout << "FE: " << index[0xFE] << std::endl;
std::cout << "FF: " << index[0xFF] << std::endl;
// 1131628 -> 7C FF FF F0
// 1131629 -> 7D 00 00 00
// ...
// 1140029 -> 7D FF FF 00
// 1140030 -> 7E 00 00 00
// ...
// 1147413 -> 7E FF FF 00
// 1147414 -> 7F 00 00 00
// std::cout << code_to_string(14323231) << std::endl;
// std::cout << code_from_string("8IzVj") << std::endl;

Loading…
Cancel
Save