Browse Source

update: CommonCode TODO list

master
Dnomd343 2 years ago
parent
commit
4c6f346ccd
  1. 2
      src/common_code/common_code.cc
  2. 10
      src/common_code/common_code.h
  3. 6
      src/main.cc
  4. 1
      src/short_code/short_code.h

2
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);

10
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
};

6
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;

1
src/short_code/short_code.h

@ -1,5 +1,6 @@
#pragma once
#include <string>
#include <cstdint>
#include <ostream>
#include "common_code.h"

Loading…
Cancel
Save