solve hw-9
This commit is contained in:
18
hws/tiktok_trends/StringPtrUtils.h
Normal file
18
hws/tiktok_trends/StringPtrUtils.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <functional>
|
||||
|
||||
struct StringPtrHash {
|
||||
size_t operator()(const std::string* s) const {
|
||||
return std::hash<std::string>()(*s);
|
||||
}
|
||||
};
|
||||
|
||||
struct StringPtrEqual {
|
||||
bool operator()(const std::string* a, const std::string* b) const {
|
||||
if (a == b) return true;
|
||||
if (!a || !b) return false;
|
||||
return *a == *b;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user