Browse Source

fix: change as inline function

legacy
dnomd343 2 years ago
parent
commit
4ebe685892
  1. 8
      case.cc
  2. 11
      common.cc
  3. 1
      common.h
  4. BIN
      klotski

8
case.cc

@ -6,6 +6,14 @@ bool check_case(int head, uint32_t range);
void build_base_range(std::vector<uint32_t> &base_range);
void gen_range(std::vector<uint32_t> &release, int n1, int n2, int n3, int n4);
inline int binary_num(uint32_t binary, int length) { // get number of non-zero bit
int num = 0;
for (int i = 0; i < length; ++i) {
num += int((binary >> i) & 0x1);
}
return num;
}
void find_all_case(std::vector<uint64_t> *all_case) {
all_case->clear();
std::vector<uint32_t> base_range;

11
common.cc

@ -1,15 +1,5 @@
#include "common.h"
//inline int binary_num(uint32_t binary, int length) { // get number of non-zero bit
int binary_num(uint32_t binary, int length) { // get number of non-zero bit
int num = 0;
for (int i = 0; i < length; ++i) {
num += int((binary >> i) & 0x1);
}
return num;
}
//inline void binary_reverse(uint32_t &range) { // reverse binary every 2 bits
void binary_reverse(uint32_t &range) { // reverse binary every 2 bits
range = ((range << 16) & 0xFFFF0000) | ((range >> 16) & 0x0000FFFF);
range = ((range << 8) & 0xFF00FF00) | ((range >> 8) & 0x00FF00FF);
@ -17,7 +7,6 @@ void binary_reverse(uint32_t &range) { // reverse binary every 2 bits
range = ((range << 2) & 0xCCCCCCCC) | ((range >> 2) & 0x33333333);
}
//inline void binary_to_str(uint64_t binary, char *string) {
void binary_to_str(uint64_t binary, char *string) {
for (int i = 0; i < 9; ++i, ++string) { // only read low 9 * 4 bits
*string = int8_t(binary >> (8 - i) * 4 & 0xF);

1
common.h

@ -4,7 +4,6 @@
#include <cstdint>
void binary_reverse(uint32_t &range);
int binary_num(uint32_t binary, int length);
void binary_to_str(uint64_t binary, char *string);
#endif

BIN
klotski

Binary file not shown.
Loading…
Cancel
Save