Fix HashTable::operator->.
This commit is contained in:
parent
a0a135dbda
commit
acf30d3700
@ -156,7 +156,7 @@ class FlatHashTableChunks {
|
|||||||
return it_->get_public();
|
return it_->get_public();
|
||||||
}
|
}
|
||||||
pointer operator->() {
|
pointer operator->() {
|
||||||
return &*it_;
|
return &it_->get_public();
|
||||||
}
|
}
|
||||||
bool operator==(const Iterator &other) const {
|
bool operator==(const Iterator &other) const {
|
||||||
DCHECK(map_ == other.map_);
|
DCHECK(map_ == other.map_);
|
||||||
|
@ -71,7 +71,7 @@ class FlatHashTable {
|
|||||||
return it_->get_public();
|
return it_->get_public();
|
||||||
}
|
}
|
||||||
pointer operator->() {
|
pointer operator->() {
|
||||||
return &*it_;
|
return &it_->get_public();
|
||||||
}
|
}
|
||||||
NodeT *get() {
|
NodeT *get() {
|
||||||
return it_;
|
return it_;
|
||||||
|
@ -77,6 +77,29 @@ TEST(FlatHashMap, probing) {
|
|||||||
test(8192, static_cast<int>(8192 * 0.3));
|
test(8192, static_cast<int>(8192 * 0.3));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct A {
|
||||||
|
int a;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct AHash {
|
||||||
|
std::size_t operator()(A a) const {
|
||||||
|
return std::hash<int>()(a.a);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
static bool operator==(const A &lhs, const A &rhs) {
|
||||||
|
return lhs.a == rhs.a;
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(FlatHashSet, foreach) {
|
||||||
|
td::FlatHashSet<A, AHash> s;
|
||||||
|
for (auto it : s) {
|
||||||
|
LOG(ERROR) << it.a;
|
||||||
|
}
|
||||||
|
s.insert({1});
|
||||||
|
LOG(INFO) << s.begin()->a;
|
||||||
|
}
|
||||||
|
|
||||||
TEST(FlatHashSet, TL) {
|
TEST(FlatHashSet, TL) {
|
||||||
td::FlatHashSet<int> s;
|
td::FlatHashSet<int> s;
|
||||||
int N = 100000;
|
int N = 100000;
|
||||||
|
Loading…
Reference in New Issue
Block a user