mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 01:20:25 +00:00
AK: Remove specialized shuffle for NonnullPtrVector
This commit is contained in:
parent
7369d0ab5f
commit
d57b09b7cf
Notes:
sideshowbarker
2024-07-17 06:40:21 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/d57b09b7cf
1 changed files with 0 additions and 13 deletions
13
AK/Random.h
13
AK/Random.h
|
@ -63,19 +63,6 @@ inline void shuffle(Collection& collection)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// shuffle() implementation for NonnullPtrVector, since its operator[] returns a reference to the pointed-at value
|
|
||||||
// instead of the pointer itself.
|
|
||||||
template<typename Collection>
|
|
||||||
requires(requires(Collection collection) { collection.ptr_at(0); })
|
|
||||||
inline void shuffle(Collection& collection)
|
|
||||||
{
|
|
||||||
// Fisher-Yates shuffle
|
|
||||||
for (size_t i = collection.size() - 1; i >= 1; --i) {
|
|
||||||
size_t j = get_random_uniform(i + 1);
|
|
||||||
AK::swap(collection.ptr_at(i), collection.ptr_at(j));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if USING_AK_GLOBALLY
|
#if USING_AK_GLOBALLY
|
||||||
|
|
Loading…
Reference in a new issue