Created
December 19, 2019 15:58
-
-
Save Milerius/4f4f889400307e16d1eb5ab80ca56311 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ConstIterator { | |
public: | |
friend class ConcurrentHashMap; | |
const value_type& operator*() const { | |
return *it_; | |
} | |
const value_type* operator->() const { | |
return &*it_; | |
} | |
ConstIterator& operator++() { | |
++it_; | |
next(); | |
return *this; | |
} | |
bool operator==(const ConstIterator& o) const { | |
return it_ == o.it_ && segment_ == o.segment_; | |
} | |
bool operator!=(const ConstIterator& o) const { | |
return !(*this == o); | |
} | |
ConstIterator& operator=(const ConstIterator& o) = delete; | |
ConstIterator& operator=(ConstIterator&& o) noexcept { | |
if (this != &o) { | |
it_ = std::move(o.it_); | |
segment_ = std::exchange(o.segment_, uint64_t(NumShards)); | |
parent_ = std::exchange(o.parent_, nullptr); | |
} | |
return *this; | |
} | |
ConstIterator(const ConstIterator& o) = delete; | |
ConstIterator(ConstIterator&& o) noexcept | |
: it_(std::move(o.it_)), | |
segment_(std::exchange(o.segment_, uint64_t(NumShards))), | |
parent_(std::exchange(o.parent_, nullptr)) {} | |
ConstIterator(const ConcurrentHashMap* parent, uint64_t segment) | |
: segment_(segment), parent_(parent) {} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment