mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-06-25 15:20:31 -04:00
Formatted code (#1007)
* Updated style * Updated files * fixed new line * Updated spacing * File fix WIP * Updated to clang 13 * updated comment style * Removed old comment code
This commit is contained in:
parent
7aca7ce74d
commit
033c4e9a5b
599 changed files with 70746 additions and 66896 deletions
|
@ -26,48 +26,46 @@
|
|||
#include <cstddef>
|
||||
|
||||
class BitHistory {
|
||||
public:
|
||||
void add(const uint_fast8_t bit) {
|
||||
history = (history << 1) | (bit & 1);
|
||||
}
|
||||
public:
|
||||
void add(const uint_fast8_t bit) {
|
||||
history = (history << 1) | (bit & 1);
|
||||
}
|
||||
|
||||
uint64_t value() const {
|
||||
return history;
|
||||
}
|
||||
uint64_t value() const {
|
||||
return history;
|
||||
}
|
||||
|
||||
private:
|
||||
uint64_t history { 0 };
|
||||
private:
|
||||
uint64_t history{0};
|
||||
};
|
||||
|
||||
class BitPattern {
|
||||
public:
|
||||
constexpr BitPattern(
|
||||
) : code_ { 0 },
|
||||
mask_ { 0 },
|
||||
maximum_hanning_distance_ { 0 }
|
||||
{
|
||||
}
|
||||
|
||||
constexpr BitPattern(
|
||||
const uint64_t code,
|
||||
const size_t code_length,
|
||||
const size_t maximum_hanning_distance = 0
|
||||
) : code_ { code },
|
||||
mask_ { (1ULL << code_length) - 1ULL },
|
||||
maximum_hanning_distance_ { maximum_hanning_distance }
|
||||
{
|
||||
}
|
||||
public:
|
||||
constexpr BitPattern()
|
||||
: code_{0},
|
||||
mask_{0},
|
||||
maximum_hanning_distance_{0} {
|
||||
}
|
||||
|
||||
bool operator()(const BitHistory& history, const size_t) const {
|
||||
const auto delta_bits = (history.value() ^ code_) & mask_;
|
||||
const size_t count = __builtin_popcountll(delta_bits);
|
||||
return (count <= maximum_hanning_distance_);
|
||||
}
|
||||
constexpr BitPattern(
|
||||
const uint64_t code,
|
||||
const size_t code_length,
|
||||
const size_t maximum_hanning_distance = 0)
|
||||
: code_{code},
|
||||
mask_{(1ULL << code_length) - 1ULL},
|
||||
maximum_hanning_distance_{maximum_hanning_distance} {
|
||||
}
|
||||
|
||||
private:
|
||||
uint64_t code_;
|
||||
uint64_t mask_;
|
||||
size_t maximum_hanning_distance_;
|
||||
bool operator()(const BitHistory& history, const size_t) const {
|
||||
const auto delta_bits = (history.value() ^ code_) & mask_;
|
||||
const size_t count = __builtin_popcountll(delta_bits);
|
||||
return (count <= maximum_hanning_distance_);
|
||||
}
|
||||
|
||||
private:
|
||||
uint64_t code_;
|
||||
uint64_t mask_;
|
||||
size_t maximum_hanning_distance_;
|
||||
};
|
||||
|
||||
#endif/*__BIT_PATTERN_H__*/
|
||||
#endif /*__BIT_PATTERN_H__*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue