MCPcopy Create free account
hub / github.com/EasyRPG/Player / SortRange

Method SortRange

src/game_variables.cpp:502–516  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

500}
501
502void Game_Variables::SortRange(int first_id, int last_id, bool asc) {
503 PrepareRange(first_id, last_id, "Invalid write sort(var[{},{}])!");
504 auto& vv = _variables;
505 int i = std::max(0, first_id - 1);
506 if (i < last_id) {
507 auto sorter = [&](auto&& fn) {
508 std::stable_sort(vv.begin() + i, vv.begin() + last_id, fn);
509 };
510 if (asc) {
511 sorter(std::less<>());
512 } else {
513 sorter(std::greater<>());
514 }
515 }
516}
517
518void Game_Variables::ShuffleRange(int first_id, int last_id) {
519 PrepareRange(first_id, last_id, "Invalid write shuffle(var[{},{}])!");

Callers 2

variables.cppFile · 0.80

Calls 2

maxFunction · 0.85
beginMethod · 0.45

Tested by

no test coverage detected