mirror of
https://github.com/savoirfairelinux/opendht.git
synced 2026-11-08 04:21:51 +00:00
InfoHash: add operator==
This commit is contained in:
1 parent
a3f4388556
commit
d87a4ef28c
1 file changed
+10
-2
@@ -250,8 +250,16 @@ public:
|
||||
return v;
|
||||
}
|
||||
|
||||
bool
|
||||
operator<(const InfoHash& o) const {
|
||||
bool operator==(const InfoHash& h) const {
|
||||
auto a = reinterpret_cast<const uint32_t*>(data());
|
||||
auto b = reinterpret_cast<const uint32_t*>(h.data());
|
||||
for (size_t i=0; i<(size()/sizeof(uint32_t)); i++)
|
||||
if (a[i] != b[i])
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool operator<(const InfoHash& o) const {
|
||||
for(unsigned i = 0; i < HASH_LEN; i++) {
|
||||
if((*this)[i] != o[i])
|
||||
return (*this)[i] < o[i];
|
||||
|
||||
Reference in new issue
Block a user