aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/cxxsupp/libcxx/include/__algorithm/shuffle.h
diff options
context:
space:
mode:
authorAlexSm <alex@ydb.tech>2023-12-27 23:31:58 +0100
committerGitHub <noreply@github.com>2023-12-27 23:31:58 +0100
commitd67bfb4b4b7549081543e87a31bc6cb5c46ac973 (patch)
tree8674f2f1570877cb653e7ddcff37ba00288de15a /contrib/libs/cxxsupp/libcxx/include/__algorithm/shuffle.h
parent1f6bef05ed441c3aa2d565ac792b26cded704ac7 (diff)
downloadydb-d67bfb4b4b7549081543e87a31bc6cb5c46ac973.tar.gz
Import libs 4 (#758)
Diffstat (limited to 'contrib/libs/cxxsupp/libcxx/include/__algorithm/shuffle.h')
-rw-r--r--contrib/libs/cxxsupp/libcxx/include/__algorithm/shuffle.h19
1 files changed, 13 insertions, 6 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/include/__algorithm/shuffle.h b/contrib/libs/cxxsupp/libcxx/include/__algorithm/shuffle.h
index 6c6ff5675d..0778815621 100644
--- a/contrib/libs/cxxsupp/libcxx/include/__algorithm/shuffle.h
+++ b/contrib/libs/cxxsupp/libcxx/include/__algorithm/shuffle.h
@@ -9,11 +9,13 @@
#ifndef _LIBCPP___ALGORITHM_SHUFFLE_H
#define _LIBCPP___ALGORITHM_SHUFFLE_H
+#include <__algorithm/iterator_operations.h>
#include <__config>
#include <__debug>
#include <__iterator/iterator_traits.h>
#include <__random/uniform_int_distribution.h>
-#include <__utility/swap.h>
+#include <__utility/forward.h>
+#include <__utility/move.h>
#include <cstddef>
#include <cstdint>
@@ -134,10 +136,8 @@ random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
}
#endif
-template<class _RandomAccessIterator, class _UniformRandomNumberGenerator>
- void shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
- _UniformRandomNumberGenerator&& __g)
-{
+template <class _AlgPolicy, class _RandomAccessIterator, class _UniformRandomNumberGenerator>
+void __shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last, _UniformRandomNumberGenerator&& __g) {
typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
typedef uniform_int_distribution<ptrdiff_t> _Dp;
typedef typename _Dp::param_type _Pp;
@@ -149,11 +149,18 @@ template<class _RandomAccessIterator, class _UniformRandomNumberGenerator>
{
difference_type __i = __uid(__g, _Pp(0, __d));
if (__i != difference_type(0))
- swap(*__first, *(__first + __i));
+ _IterOps<_AlgPolicy>::iter_swap(__first, __first + __i);
}
}
}
+template <class _RandomAccessIterator, class _UniformRandomNumberGenerator>
+void shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last,
+ _UniformRandomNumberGenerator&& __g) {
+ std::__shuffle<_ClassicAlgPolicy>(
+ std::move(__first), std::move(__last), std::forward<_UniformRandomNumberGenerator>(__g));
+}
+
_LIBCPP_END_NAMESPACE_STD
_LIBCPP_POP_MACROS