Skip to content

Commit

Permalink
refactor(memory): swap atLeft and atRight names
Browse files Browse the repository at this point in the history
These method names were inconsistent with the equivalent contains methods
  • Loading branch information
RiscadoA committed Nov 21, 2023
1 parent 11b4030 commit 70583c4
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions core/include/cubos/core/memory/unordered_bimap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ namespace cubos::core::memory
/// @note Aborts if the left value isn't stored.
/// @param left Left value.
/// @return Right value.
const R& atRight(const L& left) const
const R& atLeft(const L& left) const
{
return mLeftToRight.at(left);
}
Expand All @@ -117,7 +117,7 @@ namespace cubos::core::memory
/// @note Aborts if the right value isn't stored.
/// @param right Right value.
/// @return Left value.
const L& atLeft(const R& right) const
const L& atRight(const R& right) const
{
return mRightToLeft.at(right);
}
Expand Down
4 changes: 2 additions & 2 deletions core/tests/ecs/blueprint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ TEST_CASE("ecs::Blueprint")
blueprint.add(foo, IntegerComponent{0});

// Searching for an entity with the same name should return the same identifier
CHECK(blueprint.bimap().atLeft("foo") == foo);
CHECK(blueprint.bimap().atRight("foo") == foo);

blueprint.clear();
}
Expand Down Expand Up @@ -84,7 +84,7 @@ TEST_CASE("ecs::Blueprint")
merged.merge("sub", blueprint);

// Then the new blueprint has the correct entities.
CHECK(merged.bimap().atLeft("foo") == foo);
CHECK(merged.bimap().atRight("foo") == foo);
CHECK(merged.bimap().containsRight("sub.bar"));
CHECK(merged.bimap().containsRight("sub.baz"));

Expand Down
16 changes: 8 additions & 8 deletions core/tests/memory/unordered_bimap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ TEST_CASE("memory::UnorderedBimap")
CHECK(bimap.contains(1, 'a'));
CHECK(bimap.containsLeft(1));
CHECK(bimap.containsRight('a'));
CHECK(bimap.atLeft('a') == 1);
CHECK(bimap.atRight(1) == 'a');
CHECK(bimap.atRight('a') == 1);
CHECK(bimap.atLeft(1) == 'a');

CHECK(bimap.begin() != bimap.end());
CHECK(bimap.begin()->first == 1);
Expand All @@ -35,19 +35,19 @@ TEST_CASE("memory::UnorderedBimap")
CHECK(bimap.size() == 2);
CHECK(bimap.contains(1, 'a'));
CHECK(bimap.contains(2, 'b'));
CHECK(bimap.atRight(1) == 'a');
CHECK(bimap.atRight(2) == 'b');
CHECK(bimap.atLeft('a') == 1);
CHECK(bimap.atLeft('b') == 2);
CHECK(bimap.atLeft(1) == 'a');
CHECK(bimap.atLeft(2) == 'b');
CHECK(bimap.atRight('a') == 1);
CHECK(bimap.atRight('b') == 2);

bimap.insert(1, 'b');

CHECK(bimap.size() == 1);
CHECK(bimap.contains(1, 'b'));
CHECK_FALSE(bimap.contains(1, 'a'));
CHECK_FALSE(bimap.contains(2, 'b'));
CHECK(bimap.atRight(1) == 'b');
CHECK(bimap.atLeft('b') == 1);
CHECK(bimap.atLeft(1) == 'b');
CHECK(bimap.atRight('b') == 1);

SUBCASE("remove left")
{
Expand Down
4 changes: 2 additions & 2 deletions engine/src/cubos/engine/scene/bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ bool SceneBridge::loadFromFile(Assets& assets, const AnyAsset& handle, Stream& s
return false;
}

entity = scene.blueprint.bimap().atLeft(name);
entity = scene.blueprint.bimap().atRight(name);
return true;
});

Expand Down Expand Up @@ -132,7 +132,7 @@ bool SceneBridge::loadFromFile(Assets& assets, const AnyAsset& handle, Stream& s
return false;
}

auto entity = scene.blueprint.bimap().atLeft(entityName);
auto entity = scene.blueprint.bimap().atRight(entityName);

for (const auto& [componentName, componentJSON] : entityJSON.items())
{
Expand Down

0 comments on commit 70583c4

Please sign in to comment.