|
@ -7,10 +7,14 @@ |
|
|
class ShortCode { |
|
|
class ShortCode { |
|
|
public: |
|
|
public: |
|
|
|
|
|
|
|
|
|
|
|
enum Mode {NORMAL, FAST}; |
|
|
|
|
|
|
|
|
|
|
|
std::vector<uint32_t> basic_ranges; |
|
|
|
|
|
|
|
|
std::vector<uint64_t> all_cases_list; // short_code -> common_code
|
|
|
std::vector<uint64_t> all_cases_list; // short_code -> common_code
|
|
|
std::unordered_map<uint64_t, uint32_t> all_cases_dict; // common_code -> short_code
|
|
|
std::unordered_map<uint64_t, uint32_t> all_cases_dict; // common_code -> short_code
|
|
|
|
|
|
|
|
|
void speed_up(); |
|
|
void speed_up(enum Mode mode); |
|
|
|
|
|
|
|
|
// uint32_t zip_short_code(uint64_t code);
|
|
|
// uint32_t zip_short_code(uint64_t code);
|
|
|
// uint64_t unzip_short_code(uint32_t short_code);
|
|
|
// uint64_t unzip_short_code(uint32_t short_code);
|
|
@ -18,11 +22,14 @@ public: |
|
|
uint64_t fast_decode(uint32_t short_code); |
|
|
uint64_t fast_decode(uint32_t short_code); |
|
|
uint32_t fast_encode(uint64_t common_code); |
|
|
uint32_t fast_encode(uint64_t common_code); |
|
|
|
|
|
|
|
|
|
|
|
uint64_t tiny_decode(uint32_t short_code); |
|
|
|
|
|
uint32_t tiny_encode(uint64_t common_code); |
|
|
|
|
|
|
|
|
private: |
|
|
private: |
|
|
// std::vector<uint64_t> all_cases_list; // short_code -> common_code
|
|
|
// std::vector<uint64_t> all_cases_list; // short_code -> common_code
|
|
|
// std::unordered_map<uint64_t, uint32_t> all_cases_dict; // common_code -> short_code
|
|
|
// std::unordered_map<uint64_t, uint32_t> all_cases_dict; // common_code -> short_code
|
|
|
|
|
|
|
|
|
void build_mapping(); |
|
|
void build_mappings(); |
|
|
|
|
|
void build_base_ranges(); |
|
|
|
|
|
|
|
|
}; |
|
|
}; |
|
|