Tidied BiMap class
This commit is contained in:
@@ -32,15 +32,15 @@ namespace Bloom
|
||||
}
|
||||
}
|
||||
|
||||
bool contains(TypeA key) const {
|
||||
bool contains(const TypeA& key) const {
|
||||
return this->map.find(key) != this->map.end();
|
||||
}
|
||||
|
||||
bool contains(TypeB key) const {
|
||||
bool contains(const TypeB& key) const {
|
||||
return this->flippedMap.find(key) != this->flippedMap.end();
|
||||
}
|
||||
|
||||
std::optional<TypeB> valueAt(TypeA key) const {
|
||||
std::optional<TypeB> valueAt(const TypeA& key) const {
|
||||
std::optional<TypeB> output;
|
||||
|
||||
if (this->contains(key)) {
|
||||
@@ -50,7 +50,7 @@ namespace Bloom
|
||||
return output;
|
||||
}
|
||||
|
||||
std::optional<TypeA> valueAt(TypeB key) const {
|
||||
std::optional<TypeA> valueAt(const TypeB& key) const {
|
||||
std::optional<TypeA> output;
|
||||
|
||||
if (this->contains(key)) {
|
||||
@@ -60,16 +60,15 @@ namespace Bloom
|
||||
return output;
|
||||
}
|
||||
|
||||
const TypeB& at(TypeA key) const {
|
||||
const TypeB& at(const TypeA& key) const {
|
||||
return this->map.at(key);
|
||||
}
|
||||
|
||||
const TypeA& at(TypeB key) const {
|
||||
return this->flippedMap.at(key);
|
||||
const TypeA& at(const TypeB& key) const {
|
||||
return this->flippedMap.at(key)->first;
|
||||
}
|
||||
|
||||
std::unordered_map<TypeA, TypeB> getMap() const {
|
||||
[[nodiscard]] std::unordered_map<TypeA, TypeB> getMap() const {
|
||||
return this->map;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user