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();
|
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();
|
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;
|
std::optional<TypeB> output;
|
||||||
|
|
||||||
if (this->contains(key)) {
|
if (this->contains(key)) {
|
||||||
@@ -50,7 +50,7 @@ namespace Bloom
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<TypeA> valueAt(TypeB key) const {
|
std::optional<TypeA> valueAt(const TypeB& key) const {
|
||||||
std::optional<TypeA> output;
|
std::optional<TypeA> output;
|
||||||
|
|
||||||
if (this->contains(key)) {
|
if (this->contains(key)) {
|
||||||
@@ -60,16 +60,15 @@ namespace Bloom
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
const TypeB& at(TypeA key) const {
|
const TypeB& at(const TypeA& key) const {
|
||||||
return this->map.at(key);
|
return this->map.at(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
const TypeA& at(TypeB key) const {
|
const TypeA& at(const TypeB& key) const {
|
||||||
return this->flippedMap.at(key);
|
|
||||||
return this->flippedMap.at(key)->first;
|
return this->flippedMap.at(key)->first;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unordered_map<TypeA, TypeB> getMap() const {
|
[[nodiscard]] std::unordered_map<TypeA, TypeB> getMap() const {
|
||||||
return this->map;
|
return this->map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user