use remembered_stat

This commit is contained in:
starcells committed 2026-07-25 01:08:13 +08:00
1 parent 39ff890215
commit edc2c63f14
3 files changed
+22 -40

No files matched your search

+4 -11
View File
@@ -12,7 +12,7 @@
#include <unordered_set>
#include <utility>
#define CELL_SIZE 5
#define CELL_SIZE 8
#define CELL_SIZE_BITWIDTH std::bit_width(unsigned(CELL_SIZE))
#define INS_SIZE (CELL_SIZE + 1)
@@ -23,13 +23,7 @@
namespace r8veritas {
// using cell = std::bitset<CELL_SIZE>;
using cell = size_t;
using stat = struct stat {
std::array<r8veritas::cell, (1 << CELL_SIZE)> datas;
r8veritas::cell unvisited_cell = 0;
bool operator==(const r8veritas::stat &s) const {
return (this->datas == s.datas);
}
};
using stat = std::array<r8veritas::cell, (1 << CELL_SIZE)>;
using stat_ref = const stat *;
using truthtable = std::pair<const r8veritas::stat *, const r8veritas::stat *>;
using op = std::function<r8veritas::cell(r8veritas::cell)>;
@@ -87,7 +81,7 @@ namespace std {
template <> struct hash<r8veritas::stat> {
size_t operator()(const r8veritas::stat &s) const {
size_t h = 0;
for (auto i : s.datas) {
for (auto i : s) {
h ^= hash<r8veritas::cell>{}(i) + 0x9e3779b9 + (h << 6) + (h >> 2);
}
return h;
@@ -113,7 +107,7 @@ template <> struct hash<pair<r8veritas::stat_ref, r8veritas::ins_bytecode>> {
r8veritas::truthtable generate_truthtable(const r8veritas::op &operation);
std::pair<r8veritas::stat_ref, bool>
operate_ins(const r8veritas::stat_ref &last_stat, const r8veritas::ins &ins,bool is_initialization = false);
operate_ins(const r8veritas::stat_ref &last_stat, const r8veritas::ins &ins);
// true means that {stat,ins} has been operated.
static std::unordered_map<
@@ -139,5 +133,4 @@ std::ostream &operator<<(std::ostream &os, const r8veritas::stat_ref &s);
std::ostream &operator<<(std::ostream &os, const r8veritas::ins &s);
static std::unordered_set<r8veritas::stat> stat_pool;
#endif