Using std::erase for pellets possible in C++20
This commit is contained in:
parent
55fbb53591
commit
b79b2a29e8
2 changed files with 2 additions and 10 deletions
|
@ -7,11 +7,7 @@ Pellets::Pellets()
|
|||
: positions(initialPelletPositions()) {}
|
||||
|
||||
bool Pellets::eatPelletAtPosition(GridPosition p) {
|
||||
auto it = std::find(positions.begin(), positions.end(), p);
|
||||
if (it == positions.end())
|
||||
return false;
|
||||
positions.erase(it);
|
||||
return true;
|
||||
return std::erase(positions, p) > 0;
|
||||
}
|
||||
|
||||
} // namespace pacman
|
||||
|
|
|
@ -7,11 +7,7 @@ SuperPellets::SuperPellets()
|
|||
: positions(initialSuperPelletPositions()) {}
|
||||
|
||||
bool SuperPellets::eatPelletAtPosition(GridPosition p) {
|
||||
auto it = std::find(positions.begin(), positions.end(), p);
|
||||
if (it == positions.end())
|
||||
return false;
|
||||
positions.erase(it);
|
||||
return true;
|
||||
return std::erase(positions, p) > 0;
|
||||
}
|
||||
|
||||
} // namespace pacman
|
||||
|
|
Loading…
Reference in a new issue