solve hw-9
This commit is contained in:
15
hws/tiktok_trends/StringInterner.cpp
Normal file
15
hws/tiktok_trends/StringInterner.cpp
Normal file
@@ -0,0 +1,15 @@
|
||||
#include "StringInterner.h"
|
||||
|
||||
const std::string* StringInterner::intern(const std::string& str) {
|
||||
std::pair<std::unordered_set<std::string>::iterator, bool> result = pool.insert(str);
|
||||
return &(*result.first);
|
||||
}
|
||||
|
||||
const std::string* StringInterner::intern(std::string&& str) {
|
||||
std::pair<std::unordered_set<std::string>::iterator, bool> result = pool.insert(std::move(str));
|
||||
return &(*result.first);
|
||||
}
|
||||
|
||||
const std::string* StringInterner::getEmptyString() {
|
||||
return intern("");
|
||||
}
|
||||
Reference in New Issue
Block a user