Browse Source

feat: test init process of struct

master
Dnomd343 2 years ago
parent
commit
5db8a3681d
  1. 16
      src/analyse/analyse.h
  2. 15
      src/analyse/backtrack.cc

16
src/analyse/analyse.h

@ -11,6 +11,18 @@
// TODO: try double or 4-times size
const uint32_t ANY_MAP_RESERVE = 65536;
#include <iostream>
class Test {
public:
Test() {
std::cout << "Test init" << std::endl;
}
~Test() {
std::cout << "Test destroy" << std::endl;
}
};
class Analyse {
public:
typedef std::function<bool(uint64_t)> match_t;
@ -45,11 +57,15 @@ private:
public:
struct backtrack_t {
// backtrack_t(int i);
uint64_t code;
uint32_t layer_num;
std::list<backtrack_t*> last;
std::list<backtrack_t*> next;
Test test;
// bool operator==(const backtrack_t &b) const {
// return b.code == code;
// }

15
src/analyse/backtrack.cc

@ -11,7 +11,7 @@ namespace std {
template<>
struct hash<Analyse::backtrack_t> {
std::size_t operator()(const Analyse::backtrack_t &b) const {
// std::cout << "get hash: " << b.code << std::endl;
std::cout << "get hash: " << b.code << std::endl;
return std::hash<uint64_t>()(b.code);
}
};
@ -19,9 +19,14 @@ namespace std {
template<>
struct equal_to<Analyse::backtrack_t> {
bool operator()(const Analyse::backtrack_t &b1, const Analyse::backtrack_t &b2) const {
// std::cout << "get eq: " << b1.code << " ? " << b2.code << std::endl;
std::cout << "get eq: " << b1.code << " ? " << b2.code << std::endl;
return b1.code == b2.code;
}
// bool operator()(const Analyse::backtrack_t &b, uint64_t c) const {
// std::cout << "eq: " << b.code << " ? " << c << std::endl;
// return b.code == c;
// }
};
}
@ -41,6 +46,7 @@ void Analyse::backtrack_demo(uint64_t code) {
.layer_num = 1,
.last = std::list<backtrack_t*>{},
.next = std::list<backtrack_t*>{},
});
}
@ -53,4 +59,9 @@ void Analyse::backtrack_demo(uint64_t code) {
std::cout << "bucket " << i << " -> " << test.bucket_size(i) << std::endl;
}
uint64_t dat = 4000;
auto ret = test.find((backtrack_t&)(dat));
std::cout << "insert demo ending" << std::endl;
}

Loading…
Cancel
Save