mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-04 21:40:33 +00:00
ColorLines: Use AK::shuffle() for shuffling
This commit is contained in:
parent
5b273f3823
commit
4b525fc98e
Notes:
sideshowbarker
2024-07-17 01:28:36 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/4b525fc98e Pull-request: https://github.com/SerenityOS/serenity/pull/17104
1 changed files with 1 additions and 9 deletions
|
@ -62,7 +62,7 @@ public:
|
|||
result.append(point);
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
random_shuffle(result);
|
||||
shuffle(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -336,14 +336,6 @@ private:
|
|||
return true;
|
||||
}
|
||||
|
||||
static void random_shuffle(PointArray& points)
|
||||
{
|
||||
// Using Fisher–Yates in-place shuffle
|
||||
if (points.size() > 1)
|
||||
for (size_t i = points.size() - 1; i > 1; --i)
|
||||
swap(points[i], points[get_random_uniform(i + 1)]);
|
||||
}
|
||||
|
||||
static constexpr int number_of_marbles_to_remove { 5 };
|
||||
|
||||
using Row = Array<Color, board_size.width()>;
|
||||
|
|
Loading…
Reference in a new issue