From 4c6f346ccde74cfce91506066b70a55f670f43aa Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Mon, 16 Jan 2023 21:04:05 +0800 Subject: [PATCH] update: CommonCode TODO list --- src/common_code/common_code.cc | 2 +- src/common_code/common_code.h | 10 +++++++++- src/main.cc | 6 ++++-- src/short_code/short_code.h | 1 + 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/common_code/common_code.cc b/src/common_code/common_code.cc index 2df92e5..b3a7870 100644 --- a/src/common_code/common_code.cc +++ b/src/common_code/common_code.cc @@ -11,7 +11,7 @@ inline uint32_t binary_count(uint32_t bin) { // get number of non-zero bits return bin & 0b111111; } -/// WARN: bin should not be zero +/// NOTE: bin should not be zero inline uint32_t last_zero_num(uint32_t bin) { // get last zero number bin ^= (bin - 1); return __builtin_popcount(bin >> 1); diff --git a/src/common_code/common_code.h b/src/common_code/common_code.h index 0f5cf6c..ebb9679 100644 --- a/src/common_code/common_code.h +++ b/src/common_code/common_code.h @@ -23,7 +23,15 @@ public: explicit CommonCode(const ShortCode &short_code); explicit CommonCode(const std::string &common_code_str); + // TODO: std::cout << CommonCode(...) + + // TODO: CommonCode::create(...) / CommonCode::from_string(...) + // TODO: CommonCode::from_short_code(...) / CommonCode::from_raw_code(...) + + // TODO: single check function for CommonCode + // TODO: single `.cc` file for serialize + private: uint64_t code; - CommonCode() = default; // unsafe init + CommonCode() = default; // unsafe initialize }; diff --git a/src/main.cc b/src/main.cc index 125c35c..028d060 100644 --- a/src/main.cc +++ b/src/main.cc @@ -282,12 +282,14 @@ int main() { // std::cout << ShortCode(14323231).to_string() << std::endl; // std::cout << ShortCode::from_string("EP4HZ").unwrap() << std::endl; - std::cout << ShortCode("EP4HZ") << std::endl; - std::cout << ShortCode(14323231) << std::endl; +// std::cout << ShortCode("EP4HZ") << std::endl; +// std::cout << ShortCode(14323231) << std::endl; // printf("%09lX\n", ShortCode::fast_decode(14323231)); // std::cout << ShortCode::fast_encode(0x6EC0F8800) << std::endl; + std::cout << sizeof(ShortCode) << std::endl; + std::cerr << (clock() - start_time) * 1000 / CLOCKS_PER_SEC << "ms" << std::endl; // std::cerr << (clock() - start_time) * 1000000 / CLOCKS_PER_SEC << "us" << std::endl; // std::cout << "complete benchmark" << std::endl; diff --git a/src/short_code/short_code.h b/src/short_code/short_code.h index 374921c..eb6f724 100644 --- a/src/short_code/short_code.h +++ b/src/short_code/short_code.h @@ -1,5 +1,6 @@ #pragma once +#include #include #include #include "common_code.h"