[MapRotation] C++20 things
This commit is contained in:
parent
88f82d297f
commit
2c54bd7d0d
@ -21,24 +21,24 @@ namespace Components
|
|||||||
std::random_device rd;
|
std::random_device rd;
|
||||||
std::mt19937 gen(rd());
|
std::mt19937 gen(rd());
|
||||||
|
|
||||||
std::shuffle(this->rotationEntries.begin(), this->rotationEntries.end(), gen);
|
std::ranges::shuffle(this->rotationEntries_, gen);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapRotation::RotationData::addEntry(const std::string& key, const std::string& value)
|
void MapRotation::RotationData::addEntry(const std::string& key, const std::string& value)
|
||||||
{
|
{
|
||||||
this->rotationEntries.emplace_back(std::make_pair(key, value));
|
this->rotationEntries_.emplace_back(std::make_pair(key, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t MapRotation::RotationData::getEntriesSize() const
|
std::size_t MapRotation::RotationData::getEntriesSize() const
|
||||||
{
|
{
|
||||||
return this->rotationEntries.size();
|
return this->rotationEntries_.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
MapRotation::RotationData::rotationEntry& MapRotation::RotationData::getNextEntry()
|
MapRotation::RotationData::rotationEntry& MapRotation::RotationData::getNextEntry()
|
||||||
{
|
{
|
||||||
const auto index = this->index_;
|
const auto index = this->index_;
|
||||||
this->index_ = (this->index_ + 1) % this->rotationEntries.size(); // Point index_ to the next entry
|
++this->index_ %= this->rotationEntries_.size(); // Point index_ to the next entry
|
||||||
return this->rotationEntries.at(index);
|
return this->rotationEntries_.at(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapRotation::RotationData::parse(const std::string& data)
|
void MapRotation::RotationData::parse(const std::string& data)
|
||||||
|
@ -32,7 +32,7 @@ namespace Components
|
|||||||
void parse(const std::string& data);
|
void parse(const std::string& data);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<rotationEntry> rotationEntries;
|
std::vector<rotationEntry> rotationEntries_;
|
||||||
|
|
||||||
std::size_t index_;
|
std::size_t index_;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user