-
-
Notifications
You must be signed in to change notification settings - Fork 350
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
v14.4
1 parent
70c4c3d
commit c853d77
Showing
960 changed files
with
221,752 additions
and
16,557 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
[submodule "app/src/main/cpp/libcxx"] | ||
path = app/src/main/cpp/libcxx | ||
url = https://github.com/topjohnwu/libcxx.git | ||
[submodule "app/src/main/cpp/Dobby"] | ||
path = app/src/main/cpp/Dobby | ||
url = https://github.com/jmpews/Dobby.git |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
cmake_minimum_required(VERSION 3.22.1) | ||
|
||
project("playintegrityfix") | ||
|
||
link_libraries(${CMAKE_SOURCE_DIR}/libcxx/${CMAKE_ANDROID_ARCH_ABI}.a) | ||
|
||
include_directories(libcxx/include) | ||
|
||
add_library(${CMAKE_PROJECT_NAME} SHARED module.cpp) | ||
|
||
add_subdirectory(Dobby) | ||
|
||
SET_OPTION(Plugin.Android.BionicLinkerUtil ON) | ||
|
||
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE log dobby_static) |
Large diffs are not rendered by default.
Oops, something went wrong.
Submodule libcxx
deleted from
12c8f4
Binary file not shown.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
53 changes: 53 additions & 0 deletions
53
app/src/main/cpp/libcxx/include/__algorithm/adjacent_find.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// -*- C++ -*- | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCPP___ALGORITHM_ADJACENT_FIND_H | ||
#define _LIBCPP___ALGORITHM_ADJACENT_FIND_H | ||
|
||
#include <__algorithm/comp.h> | ||
#include <__algorithm/iterator_operations.h> | ||
#include <__config> | ||
#include <__iterator/iterator_traits.h> | ||
#include <__utility/move.h> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
#endif | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
template <class _Iter, class _Sent, class _BinaryPredicate> | ||
_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter | ||
__adjacent_find(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) { | ||
if (__first == __last) | ||
return __first; | ||
_Iter __i = __first; | ||
while (++__i != __last) { | ||
if (__pred(*__first, *__i)) | ||
return __first; | ||
__first = __i; | ||
} | ||
return __i; | ||
} | ||
|
||
template <class _ForwardIterator, class _BinaryPredicate> | ||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator | ||
adjacent_find(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred) { | ||
return std::__adjacent_find(std::move(__first), std::move(__last), __pred); | ||
} | ||
|
||
template <class _ForwardIterator> | ||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator | ||
adjacent_find(_ForwardIterator __first, _ForwardIterator __last) { | ||
return std::adjacent_find(std::move(__first), std::move(__last), __equal_to()); | ||
} | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
|
||
#endif // _LIBCPP___ALGORITHM_ADJACENT_FIND_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// -*- C++ -*- | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCPP___ALGORITHM_ALL_OF_H | ||
#define _LIBCPP___ALGORITHM_ALL_OF_H | ||
|
||
#include <__config> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
#endif | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
template <class _InputIterator, class _Predicate> | ||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | ||
all_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) { | ||
for (; __first != __last; ++__first) | ||
if (!__pred(*__first)) | ||
return false; | ||
return true; | ||
} | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
|
||
#endif // _LIBCPP___ALGORITHM_ALL_OF_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// -*- C++ -*- | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCPP___ALGORITHM_ANY_OF_H | ||
#define _LIBCPP___ALGORITHM_ANY_OF_H | ||
|
||
#include <__config> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
#endif | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
template <class _InputIterator, class _Predicate> | ||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | ||
any_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) { | ||
for (; __first != __last; ++__first) | ||
if (__pred(*__first)) | ||
return true; | ||
return false; | ||
} | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
|
||
#endif // _LIBCPP___ALGORITHM_ANY_OF_H |
46 changes: 46 additions & 0 deletions
46
app/src/main/cpp/libcxx/include/__algorithm/binary_search.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCPP___ALGORITHM_BINARY_SEARCH_H | ||
#define _LIBCPP___ALGORITHM_BINARY_SEARCH_H | ||
|
||
#include <__algorithm/comp.h> | ||
#include <__algorithm/comp_ref_type.h> | ||
#include <__algorithm/lower_bound.h> | ||
#include <__config> | ||
#include <__iterator/iterator_traits.h> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
#endif | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
template <class _ForwardIterator, class _Tp, class _Compare> | ||
_LIBCPP_NODISCARD_EXT inline | ||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 | ||
bool | ||
binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) | ||
{ | ||
__first = std::lower_bound<_ForwardIterator, _Tp, __comp_ref_type<_Compare> >(__first, __last, __value, __comp); | ||
return __first != __last && !__comp(__value, *__first); | ||
} | ||
|
||
template <class _ForwardIterator, class _Tp> | ||
_LIBCPP_NODISCARD_EXT inline | ||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 | ||
bool | ||
binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) | ||
{ | ||
return std::binary_search(__first, __last, __value, | ||
__less<typename iterator_traits<_ForwardIterator>::value_type, _Tp>()); | ||
} | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
|
||
#endif // _LIBCPP___ALGORITHM_BINARY_SEARCH_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCPP___ALGORITHM_CLAMP_H | ||
#define _LIBCPP___ALGORITHM_CLAMP_H | ||
|
||
#include <__algorithm/comp.h> | ||
#include <__assert> | ||
#include <__config> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
#endif | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
#if _LIBCPP_STD_VER > 14 | ||
template<class _Tp, class _Compare> | ||
_LIBCPP_NODISCARD_EXT inline | ||
_LIBCPP_INLINE_VISIBILITY constexpr | ||
const _Tp& | ||
clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi, _Compare __comp) | ||
{ | ||
_LIBCPP_ASSERT(!__comp(__hi, __lo), "Bad bounds passed to std::clamp"); | ||
return __comp(__v, __lo) ? __lo : __comp(__hi, __v) ? __hi : __v; | ||
|
||
} | ||
|
||
template<class _Tp> | ||
_LIBCPP_NODISCARD_EXT inline | ||
_LIBCPP_INLINE_VISIBILITY constexpr | ||
const _Tp& | ||
clamp(const _Tp& __v, const _Tp& __lo, const _Tp& __hi) | ||
{ | ||
return _VSTD::clamp(__v, __lo, __hi, __less<_Tp>()); | ||
} | ||
#endif | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
|
||
#endif // _LIBCPP___ALGORITHM_CLAMP_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCPP___ALGORITHM_COMP_H | ||
#define _LIBCPP___ALGORITHM_COMP_H | ||
|
||
#include <__config> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
#endif | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
struct __equal_to { | ||
template <class _T1, class _T2> | ||
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 bool operator()(const _T1& __x, const _T2& __y) const { | ||
return __x == __y; | ||
} | ||
}; | ||
|
||
template <class _T1, class _T2 = _T1> | ||
struct __less | ||
{ | ||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 | ||
bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;} | ||
|
||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 | ||
bool operator()(const _T1& __x, const _T2& __y) const {return __x < __y;} | ||
|
||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 | ||
bool operator()(const _T2& __x, const _T1& __y) const {return __x < __y;} | ||
|
||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 | ||
bool operator()(const _T2& __x, const _T2& __y) const {return __x < __y;} | ||
}; | ||
|
||
template <class _T1> | ||
struct __less<_T1, _T1> | ||
{ | ||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 | ||
bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;} | ||
}; | ||
|
||
template <class _T1> | ||
struct __less<const _T1, _T1> | ||
{ | ||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 | ||
bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;} | ||
}; | ||
|
||
template <class _T1> | ||
struct __less<_T1, const _T1> | ||
{ | ||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX14 | ||
bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;} | ||
}; | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
|
||
#endif // _LIBCPP___ALGORITHM_COMP_H |
79 changes: 79 additions & 0 deletions
79
app/src/main/cpp/libcxx/include/__algorithm/comp_ref_type.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCPP___ALGORITHM_COMP_REF_TYPE_H | ||
#define _LIBCPP___ALGORITHM_COMP_REF_TYPE_H | ||
|
||
#include <__config> | ||
#include <__debug> | ||
#include <__utility/declval.h> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
#endif | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
template <class _Compare> | ||
struct __debug_less | ||
{ | ||
_Compare &__comp_; | ||
_LIBCPP_CONSTEXPR_SINCE_CXX14 | ||
__debug_less(_Compare& __c) : __comp_(__c) {} | ||
|
||
template <class _Tp, class _Up> | ||
_LIBCPP_CONSTEXPR_SINCE_CXX14 | ||
bool operator()(const _Tp& __x, const _Up& __y) | ||
{ | ||
bool __r = __comp_(__x, __y); | ||
if (__r) | ||
__do_compare_assert(0, __y, __x); | ||
return __r; | ||
} | ||
|
||
template <class _Tp, class _Up> | ||
_LIBCPP_CONSTEXPR_SINCE_CXX14 | ||
bool operator()(_Tp& __x, _Up& __y) | ||
{ | ||
bool __r = __comp_(__x, __y); | ||
if (__r) | ||
__do_compare_assert(0, __y, __x); | ||
return __r; | ||
} | ||
|
||
template <class _LHS, class _RHS> | ||
_LIBCPP_CONSTEXPR_SINCE_CXX14 | ||
inline _LIBCPP_INLINE_VISIBILITY | ||
decltype((void)std::declval<_Compare&>()( | ||
std::declval<_LHS &>(), std::declval<_RHS &>())) | ||
__do_compare_assert(int, _LHS & __l, _RHS & __r) { | ||
_LIBCPP_DEBUG_ASSERT(!__comp_(__l, __r), | ||
"Comparator does not induce a strict weak ordering"); | ||
(void)__l; | ||
(void)__r; | ||
} | ||
|
||
template <class _LHS, class _RHS> | ||
_LIBCPP_CONSTEXPR_SINCE_CXX14 | ||
inline _LIBCPP_INLINE_VISIBILITY | ||
void __do_compare_assert(long, _LHS &, _RHS &) {} | ||
}; | ||
|
||
// Pass the comparator by lvalue reference. Or in debug mode, using a | ||
// debugging wrapper that stores a reference. | ||
#ifdef _LIBCPP_ENABLE_DEBUG_MODE | ||
template <class _Comp> | ||
using __comp_ref_type = __debug_less<_Comp>; | ||
#else | ||
template <class _Comp> | ||
using __comp_ref_type = _Comp&; | ||
#endif | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
|
||
#endif // _LIBCPP___ALGORITHM_COMP_REF_TYPE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCPP___ALGORITHM_COPY_H | ||
#define _LIBCPP___ALGORITHM_COPY_H | ||
|
||
#include <__algorithm/copy_move_common.h> | ||
#include <__algorithm/iterator_operations.h> | ||
#include <__algorithm/min.h> | ||
#include <__config> | ||
#include <__iterator/segmented_iterator.h> | ||
#include <__type_traits/common_type.h> | ||
#include <__utility/move.h> | ||
#include <__utility/pair.h> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
#endif | ||
|
||
_LIBCPP_PUSH_MACROS | ||
#include <__undef_macros> | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
template <class, class _InIter, class _Sent, class _OutIter> | ||
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> __copy(_InIter, _Sent, _OutIter); | ||
|
||
template <class _AlgPolicy> | ||
struct __copy_loop { | ||
template <class _InIter, class _Sent, class _OutIter> | ||
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> | ||
operator()(_InIter __first, _Sent __last, _OutIter __result) const { | ||
while (__first != __last) { | ||
*__result = *__first; | ||
++__first; | ||
++__result; | ||
} | ||
|
||
return std::make_pair(std::move(__first), std::move(__result)); | ||
} | ||
|
||
template <class _InIter, class _OutIter, __enable_if_t<__is_segmented_iterator<_InIter>::value, int> = 0> | ||
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> | ||
operator()(_InIter __first, _InIter __last, _OutIter __result) const { | ||
using _Traits = __segmented_iterator_traits<_InIter>; | ||
auto __sfirst = _Traits::__segment(__first); | ||
auto __slast = _Traits::__segment(__last); | ||
if (__sfirst == __slast) { | ||
auto __iters = std::__copy<_AlgPolicy>(_Traits::__local(__first), _Traits::__local(__last), std::move(__result)); | ||
return std::make_pair(__last, std::move(__iters.second)); | ||
} | ||
|
||
__result = std::__copy<_AlgPolicy>(_Traits::__local(__first), _Traits::__end(__sfirst), std::move(__result)).second; | ||
++__sfirst; | ||
while (__sfirst != __slast) { | ||
__result = | ||
std::__copy<_AlgPolicy>(_Traits::__begin(__sfirst), _Traits::__end(__sfirst), std::move(__result)).second; | ||
++__sfirst; | ||
} | ||
__result = | ||
std::__copy<_AlgPolicy>(_Traits::__begin(__sfirst), _Traits::__local(__last), std::move(__result)).second; | ||
return std::make_pair(__last, std::move(__result)); | ||
} | ||
|
||
template <class _InIter, | ||
class _OutIter, | ||
__enable_if_t<__is_cpp17_random_access_iterator<_InIter>::value && | ||
!__is_segmented_iterator<_InIter>::value && __is_segmented_iterator<_OutIter>::value, | ||
int> = 0> | ||
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> | ||
operator()(_InIter __first, _InIter __last, _OutIter __result) { | ||
using _Traits = __segmented_iterator_traits<_OutIter>; | ||
using _DiffT = typename common_type<__iter_diff_t<_InIter>, __iter_diff_t<_OutIter> >::type; | ||
|
||
if (__first == __last) | ||
return std::make_pair(std::move(__first), std::move(__result)); | ||
|
||
auto __local_first = _Traits::__local(__result); | ||
auto __segment_iterator = _Traits::__segment(__result); | ||
while (true) { | ||
auto __local_last = _Traits::__end(__segment_iterator); | ||
auto __size = std::min<_DiffT>(__local_last - __local_first, __last - __first); | ||
auto __iters = std::__copy<_AlgPolicy>(__first, __first + __size, __local_first); | ||
__first = std::move(__iters.first); | ||
|
||
if (__first == __last) | ||
return std::make_pair(std::move(__first), _Traits::__compose(__segment_iterator, std::move(__iters.second))); | ||
|
||
__local_first = _Traits::__begin(++__segment_iterator); | ||
} | ||
} | ||
}; | ||
|
||
struct __copy_trivial { | ||
// At this point, the iterators have been unwrapped so any `contiguous_iterator` has been unwrapped to a pointer. | ||
template <class _In, class _Out, | ||
__enable_if_t<__can_lower_copy_assignment_to_memmove<_In, _Out>::value, int> = 0> | ||
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*> | ||
operator()(_In* __first, _In* __last, _Out* __result) const { | ||
return std::__copy_trivial_impl(__first, __last, __result); | ||
} | ||
}; | ||
|
||
template <class _AlgPolicy, class _InIter, class _Sent, class _OutIter> | ||
pair<_InIter, _OutIter> inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 | ||
__copy(_InIter __first, _Sent __last, _OutIter __result) { | ||
return std::__dispatch_copy_or_move<_AlgPolicy, __copy_loop<_AlgPolicy>, __copy_trivial>( | ||
std::move(__first), std::move(__last), std::move(__result)); | ||
} | ||
|
||
template <class _InputIterator, class _OutputIterator> | ||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _OutputIterator | ||
copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result) { | ||
return std::__copy<_ClassicAlgPolicy>(__first, __last, __result).second; | ||
} | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
|
||
_LIBCPP_POP_MACROS | ||
|
||
#endif // _LIBCPP___ALGORITHM_COPY_H |
143 changes: 143 additions & 0 deletions
143
app/src/main/cpp/libcxx/include/__algorithm/copy_backward.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCPP___ALGORITHM_COPY_BACKWARD_H | ||
#define _LIBCPP___ALGORITHM_COPY_BACKWARD_H | ||
|
||
#include <__algorithm/copy_move_common.h> | ||
#include <__algorithm/iterator_operations.h> | ||
#include <__algorithm/min.h> | ||
#include <__config> | ||
#include <__iterator/segmented_iterator.h> | ||
#include <__type_traits/common_type.h> | ||
#include <__type_traits/is_copy_constructible.h> | ||
#include <__utility/move.h> | ||
#include <__utility/pair.h> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
#endif | ||
|
||
_LIBCPP_PUSH_MACROS | ||
#include <__undef_macros> | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
template <class _AlgPolicy, class _InIter, class _Sent, class _OutIter> | ||
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_InIter, _OutIter> | ||
__copy_backward(_InIter __first, _Sent __last, _OutIter __result); | ||
|
||
template <class _AlgPolicy> | ||
struct __copy_backward_loop { | ||
template <class _InIter, class _Sent, class _OutIter> | ||
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> | ||
operator()(_InIter __first, _Sent __last, _OutIter __result) const { | ||
auto __last_iter = _IterOps<_AlgPolicy>::next(__first, __last); | ||
auto __original_last_iter = __last_iter; | ||
|
||
while (__first != __last_iter) { | ||
*--__result = *--__last_iter; | ||
} | ||
|
||
return std::make_pair(std::move(__original_last_iter), std::move(__result)); | ||
} | ||
|
||
template <class _InIter, class _OutIter, __enable_if_t<__is_segmented_iterator<_InIter>::value, int> = 0> | ||
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> | ||
operator()(_InIter __first, _InIter __last, _OutIter __result) const { | ||
using _Traits = __segmented_iterator_traits<_InIter>; | ||
auto __sfirst = _Traits::__segment(__first); | ||
auto __slast = _Traits::__segment(__last); | ||
if (__sfirst == __slast) { | ||
auto __iters = | ||
std::__copy_backward<_AlgPolicy>(_Traits::__local(__first), _Traits::__local(__last), std::move(__result)); | ||
return std::make_pair(__last, __iters.second); | ||
} | ||
|
||
__result = | ||
std::__copy_backward<_AlgPolicy>(_Traits::__begin(__slast), _Traits::__local(__last), std::move(__result)) | ||
.second; | ||
--__slast; | ||
while (__sfirst != __slast) { | ||
__result = | ||
std::__copy_backward<_AlgPolicy>(_Traits::__begin(__slast), _Traits::__end(__slast), std::move(__result)) | ||
.second; | ||
--__slast; | ||
} | ||
__result = std::__copy_backward<_AlgPolicy>(_Traits::__local(__first), _Traits::__end(__slast), std::move(__result)) | ||
.second; | ||
return std::make_pair(__last, std::move(__result)); | ||
} | ||
|
||
template <class _InIter, | ||
class _OutIter, | ||
__enable_if_t<__is_cpp17_random_access_iterator<_InIter>::value && | ||
!__is_segmented_iterator<_InIter>::value && __is_segmented_iterator<_OutIter>::value, | ||
int> = 0> | ||
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_InIter, _OutIter> | ||
operator()(_InIter __first, _InIter __last, _OutIter __result) { | ||
using _Traits = __segmented_iterator_traits<_OutIter>; | ||
auto __orig_last = __last; | ||
auto __segment_iterator = _Traits::__segment(__result); | ||
|
||
// When the range contains no elements, __result might not be a valid iterator | ||
if (__first == __last) | ||
return std::make_pair(__first, __result); | ||
|
||
auto __local_last = _Traits::__local(__result); | ||
while (true) { | ||
using _DiffT = typename common_type<__iter_diff_t<_InIter>, __iter_diff_t<_OutIter> >::type; | ||
|
||
auto __local_first = _Traits::__begin(__segment_iterator); | ||
auto __size = std::min<_DiffT>(__local_last - __local_first, __last - __first); | ||
auto __iter = std::__copy_backward<_AlgPolicy>(__last - __size, __last, __local_last).second; | ||
__last -= __size; | ||
|
||
if (__first == __last) | ||
return std::make_pair(std::move(__orig_last), _Traits::__compose(__segment_iterator, std::move(__iter))); | ||
--__segment_iterator; | ||
__local_last = _Traits::__end(__segment_iterator); | ||
} | ||
} | ||
}; | ||
|
||
struct __copy_backward_trivial { | ||
// At this point, the iterators have been unwrapped so any `contiguous_iterator` has been unwrapped to a pointer. | ||
template <class _In, class _Out, | ||
__enable_if_t<__can_lower_copy_assignment_to_memmove<_In, _Out>::value, int> = 0> | ||
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*> | ||
operator()(_In* __first, _In* __last, _Out* __result) const { | ||
return std::__copy_backward_trivial_impl(__first, __last, __result); | ||
} | ||
}; | ||
|
||
template <class _AlgPolicy, class _BidirectionalIterator1, class _Sentinel, class _BidirectionalIterator2> | ||
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_BidirectionalIterator1, _BidirectionalIterator2> | ||
__copy_backward(_BidirectionalIterator1 __first, _Sentinel __last, _BidirectionalIterator2 __result) { | ||
return std::__dispatch_copy_or_move<_AlgPolicy, __copy_backward_loop<_AlgPolicy>, __copy_backward_trivial>( | ||
std::move(__first), std::move(__last), std::move(__result)); | ||
} | ||
|
||
template <class _BidirectionalIterator1, class _BidirectionalIterator2> | ||
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 | ||
_BidirectionalIterator2 | ||
copy_backward(_BidirectionalIterator1 __first, _BidirectionalIterator1 __last, | ||
_BidirectionalIterator2 __result) | ||
{ | ||
static_assert(std::is_copy_constructible<_BidirectionalIterator1>::value && | ||
std::is_copy_constructible<_BidirectionalIterator1>::value, "Iterators must be copy constructible."); | ||
|
||
return std::__copy_backward<_ClassicAlgPolicy>( | ||
std::move(__first), std::move(__last), std::move(__result)).second; | ||
} | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
|
||
_LIBCPP_POP_MACROS | ||
|
||
#endif // _LIBCPP___ALGORITHM_COPY_BACKWARD_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCPP___ALGORITHM_COPY_IF_H | ||
#define _LIBCPP___ALGORITHM_COPY_IF_H | ||
|
||
#include <__config> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
#endif | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
template<class _InputIterator, class _OutputIterator, class _Predicate> | ||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 | ||
_OutputIterator | ||
copy_if(_InputIterator __first, _InputIterator __last, | ||
_OutputIterator __result, _Predicate __pred) | ||
{ | ||
for (; __first != __last; ++__first) | ||
{ | ||
if (__pred(*__first)) | ||
{ | ||
*__result = *__first; | ||
++__result; | ||
} | ||
} | ||
return __result; | ||
} | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
|
||
#endif // _LIBCPP___ALGORITHM_COPY_IF_H |
163 changes: 163 additions & 0 deletions
163
app/src/main/cpp/libcxx/include/__algorithm/copy_move_common.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCPP___ALGORITHM_COPY_MOVE_COMMON_H | ||
#define _LIBCPP___ALGORITHM_COPY_MOVE_COMMON_H | ||
|
||
#include <__algorithm/iterator_operations.h> | ||
#include <__algorithm/unwrap_iter.h> | ||
#include <__algorithm/unwrap_range.h> | ||
#include <__config> | ||
#include <__iterator/iterator_traits.h> | ||
#include <__memory/pointer_traits.h> | ||
#include <__type_traits/enable_if.h> | ||
#include <__type_traits/is_always_bitcastable.h> | ||
#include <__type_traits/is_constant_evaluated.h> | ||
#include <__type_traits/is_copy_constructible.h> | ||
#include <__type_traits/is_trivially_assignable.h> | ||
#include <__type_traits/is_trivially_copyable.h> | ||
#include <__type_traits/is_volatile.h> | ||
#include <__utility/move.h> | ||
#include <__utility/pair.h> | ||
#include <cstddef> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
#endif | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
// Type traits. | ||
|
||
template <class _From, class _To> | ||
struct __can_lower_copy_assignment_to_memmove { | ||
static const bool value = | ||
// If the types are always bitcastable, it's valid to do a bitwise copy between them. | ||
__is_always_bitcastable<_From, _To>::value && | ||
// Reject conversions that wouldn't be performed by the regular built-in assignment (e.g. between arrays). | ||
is_trivially_assignable<_To&, const _From&>::value && | ||
// `memmove` doesn't accept `volatile` pointers, make sure the optimization SFINAEs away in that case. | ||
!is_volatile<_From>::value && | ||
!is_volatile<_To>::value; | ||
}; | ||
|
||
template <class _From, class _To> | ||
struct __can_lower_move_assignment_to_memmove { | ||
static const bool value = | ||
__is_always_bitcastable<_From, _To>::value && | ||
is_trivially_assignable<_To&, _From&&>::value && | ||
!is_volatile<_From>::value && | ||
!is_volatile<_To>::value; | ||
}; | ||
|
||
// `memmove` algorithms implementation. | ||
|
||
template <class _In, class _Out> | ||
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*> | ||
__copy_trivial_impl(_In* __first, _In* __last, _Out* __result) { | ||
const size_t __n = static_cast<size_t>(__last - __first); | ||
::__builtin_memmove(__result, __first, __n * sizeof(_Out)); | ||
|
||
return std::make_pair(__last, __result + __n); | ||
} | ||
|
||
template <class _In, class _Out> | ||
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_In*, _Out*> | ||
__copy_backward_trivial_impl(_In* __first, _In* __last, _Out* __result) { | ||
const size_t __n = static_cast<size_t>(__last - __first); | ||
__result -= __n; | ||
|
||
::__builtin_memmove(__result, __first, __n * sizeof(_Out)); | ||
|
||
return std::make_pair(__last, __result); | ||
} | ||
|
||
// Iterator unwrapping and dispatching to the correct overload. | ||
|
||
template <class _F1, class _F2> | ||
struct __overload : _F1, _F2 { | ||
using _F1::operator(); | ||
using _F2::operator(); | ||
}; | ||
|
||
template <class _InIter, class _Sent, class _OutIter, class = void> | ||
struct __can_rewrap : false_type {}; | ||
|
||
template <class _InIter, class _Sent, class _OutIter> | ||
struct __can_rewrap<_InIter, | ||
_Sent, | ||
_OutIter, | ||
// Note that sentinels are always copy-constructible. | ||
__enable_if_t< is_copy_constructible<_InIter>::value && | ||
is_copy_constructible<_OutIter>::value > > : true_type {}; | ||
|
||
template <class _Algorithm, | ||
class _InIter, | ||
class _Sent, | ||
class _OutIter, | ||
__enable_if_t<__can_rewrap<_InIter, _Sent, _OutIter>::value, int> = 0> | ||
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 pair<_InIter, _OutIter> | ||
__unwrap_and_dispatch(_InIter __first, _Sent __last, _OutIter __out_first) { | ||
auto __range = std::__unwrap_range(__first, std::move(__last)); | ||
auto __result = _Algorithm()(std::move(__range.first), std::move(__range.second), std::__unwrap_iter(__out_first)); | ||
return std::make_pair(std::__rewrap_range<_Sent>(std::move(__first), std::move(__result.first)), | ||
std::__rewrap_iter(std::move(__out_first), std::move(__result.second))); | ||
} | ||
|
||
template <class _Algorithm, | ||
class _InIter, | ||
class _Sent, | ||
class _OutIter, | ||
__enable_if_t<!__can_rewrap<_InIter, _Sent, _OutIter>::value, int> = 0> | ||
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 pair<_InIter, _OutIter> | ||
__unwrap_and_dispatch(_InIter __first, _Sent __last, _OutIter __out_first) { | ||
return _Algorithm()(std::move(__first), std::move(__last), std::move(__out_first)); | ||
} | ||
|
||
template <class _IterOps, class _InValue, class _OutIter, class = void> | ||
struct __can_copy_without_conversion : false_type {}; | ||
|
||
template <class _IterOps, class _InValue, class _OutIter> | ||
struct __can_copy_without_conversion< | ||
_IterOps, | ||
_InValue, | ||
_OutIter, | ||
__enable_if_t<is_same<_InValue, typename _IterOps::template __value_type<_OutIter> >::value> > : true_type {}; | ||
|
||
template <class _AlgPolicy, | ||
class _NaiveAlgorithm, | ||
class _OptimizedAlgorithm, | ||
class _InIter, | ||
class _Sent, | ||
class _OutIter> | ||
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX17 pair<_InIter, _OutIter> | ||
__dispatch_copy_or_move(_InIter __first, _Sent __last, _OutIter __out_first) { | ||
#ifdef _LIBCPP_COMPILER_GCC | ||
// GCC doesn't support `__builtin_memmove` during constant evaluation. | ||
if (__libcpp_is_constant_evaluated()) { | ||
return std::__unwrap_and_dispatch<_NaiveAlgorithm>(std::move(__first), std::move(__last), std::move(__out_first)); | ||
} | ||
#else | ||
// In Clang, `__builtin_memmove` only supports fully trivially copyable types (just having trivial copy assignment is | ||
// insufficient). Also, conversions are not supported. | ||
if (__libcpp_is_constant_evaluated()) { | ||
using _InValue = typename _IterOps<_AlgPolicy>::template __value_type<_InIter>; | ||
if (!is_trivially_copyable<_InValue>::value || | ||
!__can_copy_without_conversion<_IterOps<_AlgPolicy>, _InValue, _OutIter>::value) { | ||
return std::__unwrap_and_dispatch<_NaiveAlgorithm>(std::move(__first), std::move(__last), std::move(__out_first)); | ||
} | ||
} | ||
#endif // _LIBCPP_COMPILER_GCC | ||
|
||
using _Algorithm = __overload<_NaiveAlgorithm, _OptimizedAlgorithm>; | ||
return std::__unwrap_and_dispatch<_Algorithm>(std::move(__first), std::move(__last), std::move(__out_first)); | ||
} | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
|
||
#endif // _LIBCPP___ALGORITHM_COPY_MOVE_COMMON_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCPP___ALGORITHM_COPY_N_H | ||
#define _LIBCPP___ALGORITHM_COPY_N_H | ||
|
||
#include <__algorithm/copy.h> | ||
#include <__config> | ||
#include <__iterator/iterator_traits.h> | ||
#include <__utility/convert_to_integral.h> | ||
#include <type_traits> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
#endif | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
template<class _InputIterator, class _Size, class _OutputIterator> | ||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 | ||
typename enable_if | ||
< | ||
__is_cpp17_input_iterator<_InputIterator>::value && | ||
!__is_cpp17_random_access_iterator<_InputIterator>::value, | ||
_OutputIterator | ||
>::type | ||
copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result) | ||
{ | ||
typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize; | ||
_IntegralSize __n = __orig_n; | ||
if (__n > 0) | ||
{ | ||
*__result = *__first; | ||
++__result; | ||
for (--__n; __n > 0; --__n) | ||
{ | ||
++__first; | ||
*__result = *__first; | ||
++__result; | ||
} | ||
} | ||
return __result; | ||
} | ||
|
||
template<class _InputIterator, class _Size, class _OutputIterator> | ||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 | ||
typename enable_if | ||
< | ||
__is_cpp17_random_access_iterator<_InputIterator>::value, | ||
_OutputIterator | ||
>::type | ||
copy_n(_InputIterator __first, _Size __orig_n, _OutputIterator __result) | ||
{ | ||
typedef typename iterator_traits<_InputIterator>::difference_type difference_type; | ||
typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize; | ||
_IntegralSize __n = __orig_n; | ||
return _VSTD::copy(__first, __first + difference_type(__n), __result); | ||
} | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
|
||
#endif // _LIBCPP___ALGORITHM_COPY_N_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// -*- C++ -*- | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCPP___ALGORITHM_COUNT_H | ||
#define _LIBCPP___ALGORITHM_COUNT_H | ||
|
||
#include <__config> | ||
#include <__iterator/iterator_traits.h> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
#endif | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
template <class _InputIterator, class _Tp> | ||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 | ||
typename iterator_traits<_InputIterator>::difference_type | ||
count(_InputIterator __first, _InputIterator __last, const _Tp& __value) { | ||
typename iterator_traits<_InputIterator>::difference_type __r(0); | ||
for (; __first != __last; ++__first) | ||
if (*__first == __value) | ||
++__r; | ||
return __r; | ||
} | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
|
||
#endif // _LIBCPP___ALGORITHM_COUNT_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// -*- C++ -*- | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCPP___ALGORITHM_COUNT_IF_H | ||
#define _LIBCPP___ALGORITHM_COUNT_IF_H | ||
|
||
#include <__config> | ||
#include <__iterator/iterator_traits.h> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
#endif | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
template <class _InputIterator, class _Predicate> | ||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 | ||
typename iterator_traits<_InputIterator>::difference_type | ||
count_if(_InputIterator __first, _InputIterator __last, _Predicate __pred) { | ||
typename iterator_traits<_InputIterator>::difference_type __r(0); | ||
for (; __first != __last; ++__first) | ||
if (__pred(*__first)) | ||
++__r; | ||
return __r; | ||
} | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
|
||
#endif // _LIBCPP___ALGORITHM_COUNT_IF_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// -*- C++ -*- | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCPP___ALGORITHM_EQUAL_H | ||
#define _LIBCPP___ALGORITHM_EQUAL_H | ||
|
||
#include <__algorithm/comp.h> | ||
#include <__config> | ||
#include <__iterator/distance.h> | ||
#include <__iterator/iterator_traits.h> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
#endif | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate> | ||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | ||
equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _BinaryPredicate __pred) { | ||
for (; __first1 != __last1; ++__first1, (void)++__first2) | ||
if (!__pred(*__first1, *__first2)) | ||
return false; | ||
return true; | ||
} | ||
|
||
template <class _InputIterator1, class _InputIterator2> | ||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | ||
equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2) { | ||
return std::equal(__first1, __last1, __first2, __equal_to()); | ||
} | ||
|
||
#if _LIBCPP_STD_VER > 11 | ||
template <class _BinaryPredicate, class _InputIterator1, class _InputIterator2> | ||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | ||
__equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, | ||
_BinaryPredicate __pred, input_iterator_tag, input_iterator_tag) { | ||
for (; __first1 != __last1 && __first2 != __last2; ++__first1, (void)++__first2) | ||
if (!__pred(*__first1, *__first2)) | ||
return false; | ||
return __first1 == __last1 && __first2 == __last2; | ||
} | ||
|
||
template <class _BinaryPredicate, class _RandomAccessIterator1, class _RandomAccessIterator2> | ||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | ||
__equal(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, _RandomAccessIterator2 __first2, | ||
_RandomAccessIterator2 __last2, _BinaryPredicate __pred, random_access_iterator_tag, | ||
random_access_iterator_tag) { | ||
if (_VSTD::distance(__first1, __last1) != _VSTD::distance(__first2, __last2)) | ||
return false; | ||
return _VSTD::equal<_RandomAccessIterator1, _RandomAccessIterator2, | ||
_BinaryPredicate&>(__first1, __last1, __first2, __pred); | ||
} | ||
|
||
template <class _InputIterator1, class _InputIterator2, class _BinaryPredicate> | ||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | ||
equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, | ||
_BinaryPredicate __pred) { | ||
return _VSTD::__equal<_BinaryPredicate&>( | ||
__first1, __last1, __first2, __last2, __pred, typename iterator_traits<_InputIterator1>::iterator_category(), | ||
typename iterator_traits<_InputIterator2>::iterator_category()); | ||
} | ||
|
||
template <class _InputIterator1, class _InputIterator2> | ||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | ||
equal(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) { | ||
return std::__equal( | ||
__first1, | ||
__last1, | ||
__first2, | ||
__last2, | ||
__equal_to(), | ||
typename iterator_traits<_InputIterator1>::iterator_category(), | ||
typename iterator_traits<_InputIterator2>::iterator_category()); | ||
} | ||
#endif | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
|
||
#endif // _LIBCPP___ALGORITHM_EQUAL_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCPP___ALGORITHM_EQUAL_RANGE_H | ||
#define _LIBCPP___ALGORITHM_EQUAL_RANGE_H | ||
|
||
#include <__algorithm/comp.h> | ||
#include <__algorithm/comp_ref_type.h> | ||
#include <__algorithm/half_positive.h> | ||
#include <__algorithm/iterator_operations.h> | ||
#include <__algorithm/lower_bound.h> | ||
#include <__algorithm/upper_bound.h> | ||
#include <__config> | ||
#include <__functional/identity.h> | ||
#include <__functional/invoke.h> | ||
#include <__iterator/advance.h> | ||
#include <__iterator/distance.h> | ||
#include <__iterator/iterator_traits.h> | ||
#include <__iterator/next.h> | ||
#include <__type_traits/is_callable.h> | ||
#include <__type_traits/is_copy_constructible.h> | ||
#include <__utility/move.h> | ||
#include <__utility/pair.h> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
#endif | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
template <class _AlgPolicy, class _Compare, class _Iter, class _Sent, class _Tp, class _Proj> | ||
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_Iter, _Iter> | ||
__equal_range(_Iter __first, _Sent __last, const _Tp& __value, _Compare&& __comp, _Proj&& __proj) { | ||
auto __len = _IterOps<_AlgPolicy>::distance(__first, __last); | ||
_Iter __end = _IterOps<_AlgPolicy>::next(__first, __last); | ||
while (__len != 0) { | ||
auto __half_len = std::__half_positive(__len); | ||
_Iter __mid = _IterOps<_AlgPolicy>::next(__first, __half_len); | ||
if (std::__invoke(__comp, std::__invoke(__proj, *__mid), __value)) { | ||
__first = ++__mid; | ||
__len -= __half_len + 1; | ||
} else if (std::__invoke(__comp, __value, std::__invoke(__proj, *__mid))) { | ||
__end = __mid; | ||
__len = __half_len; | ||
} else { | ||
_Iter __mp1 = __mid; | ||
return pair<_Iter, _Iter>( | ||
std::__lower_bound_impl<_AlgPolicy>(__first, __mid, __value, __comp, __proj), | ||
std::__upper_bound<_AlgPolicy>(++__mp1, __end, __value, __comp, __proj)); | ||
} | ||
} | ||
return pair<_Iter, _Iter>(__first, __first); | ||
} | ||
|
||
template <class _ForwardIterator, class _Tp, class _Compare> | ||
_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_ForwardIterator, _ForwardIterator> | ||
equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) { | ||
static_assert(__is_callable<_Compare, decltype(*__first), const _Tp&>::value, | ||
"The comparator has to be callable"); | ||
static_assert(is_copy_constructible<_ForwardIterator>::value, | ||
"Iterator has to be copy constructible"); | ||
return std::__equal_range<_ClassicAlgPolicy>( | ||
std::move(__first), | ||
std::move(__last), | ||
__value, | ||
static_cast<__comp_ref_type<_Compare> >(__comp), | ||
std::__identity()); | ||
} | ||
|
||
template <class _ForwardIterator, class _Tp> | ||
_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_ForwardIterator, _ForwardIterator> | ||
equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) { | ||
return std::equal_range( | ||
std::move(__first), | ||
std::move(__last), | ||
__value, | ||
__less<typename iterator_traits<_ForwardIterator>::value_type, _Tp>()); | ||
} | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
|
||
#endif // _LIBCPP___ALGORITHM_EQUAL_RANGE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCPP___ALGORITHM_FILL_H | ||
#define _LIBCPP___ALGORITHM_FILL_H | ||
|
||
#include <__algorithm/fill_n.h> | ||
#include <__config> | ||
#include <__iterator/iterator_traits.h> | ||
#include <type_traits> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
#endif | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
// fill isn't specialized for std::memset, because the compiler already optimizes the loop to a call to std::memset. | ||
|
||
template <class _ForwardIterator, class _Tp> | ||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 | ||
void | ||
__fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, forward_iterator_tag) | ||
{ | ||
for (; __first != __last; ++__first) | ||
*__first = __value; | ||
} | ||
|
||
template <class _RandomAccessIterator, class _Tp> | ||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 | ||
void | ||
__fill(_RandomAccessIterator __first, _RandomAccessIterator __last, const _Tp& __value, random_access_iterator_tag) | ||
{ | ||
_VSTD::fill_n(__first, __last - __first, __value); | ||
} | ||
|
||
template <class _ForwardIterator, class _Tp> | ||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 | ||
void | ||
fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) | ||
{ | ||
_VSTD::__fill(__first, __last, __value, typename iterator_traits<_ForwardIterator>::iterator_category()); | ||
} | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
|
||
#endif // _LIBCPP___ALGORITHM_FILL_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCPP___ALGORITHM_FILL_N_H | ||
#define _LIBCPP___ALGORITHM_FILL_N_H | ||
|
||
#include <__config> | ||
#include <__iterator/iterator_traits.h> | ||
#include <__utility/convert_to_integral.h> | ||
#include <type_traits> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
#endif | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
// fill_n isn't specialized for std::memset, because the compiler already optimizes the loop to a call to std::memset. | ||
|
||
template <class _OutputIterator, class _Size, class _Tp> | ||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 | ||
_OutputIterator | ||
__fill_n(_OutputIterator __first, _Size __n, const _Tp& __value) | ||
{ | ||
for (; __n > 0; ++__first, (void) --__n) | ||
*__first = __value; | ||
return __first; | ||
} | ||
|
||
template <class _OutputIterator, class _Size, class _Tp> | ||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 | ||
_OutputIterator | ||
fill_n(_OutputIterator __first, _Size __n, const _Tp& __value) | ||
{ | ||
return _VSTD::__fill_n(__first, _VSTD::__convert_to_integral(__n), __value); | ||
} | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
|
||
#endif // _LIBCPP___ALGORITHM_FILL_N_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// -*- C++ -*- | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCPP___ALGORITHM_FIND_H | ||
#define _LIBCPP___ALGORITHM_FIND_H | ||
|
||
#include <__config> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
#endif | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
template <class _InputIterator, class _Tp> | ||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator | ||
find(_InputIterator __first, _InputIterator __last, const _Tp& __value) { | ||
for (; __first != __last; ++__first) | ||
if (*__first == __value) | ||
break; | ||
return __first; | ||
} | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
|
||
#endif // _LIBCPP___ALGORITHM_FIND_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,227 @@ | ||
// -*- C++ -*- | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCPP___ALGORITHM_FIND_END_OF_H | ||
#define _LIBCPP___ALGORITHM_FIND_END_OF_H | ||
|
||
#include <__algorithm/comp.h> | ||
#include <__algorithm/iterator_operations.h> | ||
#include <__algorithm/search.h> | ||
#include <__config> | ||
#include <__functional/identity.h> | ||
#include <__iterator/advance.h> | ||
#include <__iterator/iterator_traits.h> | ||
#include <__iterator/next.h> | ||
#include <__iterator/reverse_iterator.h> | ||
#include <__utility/pair.h> | ||
#include <type_traits> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
#endif | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
template < | ||
class _AlgPolicy, | ||
class _Iter1, | ||
class _Sent1, | ||
class _Iter2, | ||
class _Sent2, | ||
class _Pred, | ||
class _Proj1, | ||
class _Proj2> | ||
_LIBCPP_HIDE_FROM_ABI inline _LIBCPP_CONSTEXPR_SINCE_CXX14 pair<_Iter1, _Iter1> __find_end_impl( | ||
_Iter1 __first1, | ||
_Sent1 __last1, | ||
_Iter2 __first2, | ||
_Sent2 __last2, | ||
_Pred& __pred, | ||
_Proj1& __proj1, | ||
_Proj2& __proj2, | ||
forward_iterator_tag, | ||
forward_iterator_tag) { | ||
// modeled after search algorithm | ||
_Iter1 __match_first = _IterOps<_AlgPolicy>::next(__first1, __last1); // __last1 is the "default" answer | ||
_Iter1 __match_last = __match_first; | ||
if (__first2 == __last2) | ||
return pair<_Iter1, _Iter1>(__match_last, __match_last); | ||
while (true) { | ||
while (true) { | ||
if (__first1 == __last1) // if source exhausted return last correct answer (or __last1 if never found) | ||
return pair<_Iter1, _Iter1>(__match_first, __match_last); | ||
if (std::__invoke(__pred, std::__invoke(__proj1, *__first1), std::__invoke(__proj2, *__first2))) | ||
break; | ||
++__first1; | ||
} | ||
// *__first1 matches *__first2, now match elements after here | ||
_Iter1 __m1 = __first1; | ||
_Iter2 __m2 = __first2; | ||
while (true) { | ||
if (++__m2 == __last2) { // Pattern exhaused, record answer and search for another one | ||
__match_first = __first1; | ||
__match_last = ++__m1; | ||
++__first1; | ||
break; | ||
} | ||
if (++__m1 == __last1) // Source exhausted, return last answer | ||
return pair<_Iter1, _Iter1>(__match_first, __match_last); | ||
// mismatch, restart with a new __first | ||
if (!std::__invoke(__pred, std::__invoke(__proj1, *__m1), std::__invoke(__proj2, *__m2))) | ||
{ | ||
++__first1; | ||
break; | ||
} // else there is a match, check next elements | ||
} | ||
} | ||
} | ||
|
||
template < | ||
class _IterOps, | ||
class _Pred, | ||
class _Iter1, | ||
class _Sent1, | ||
class _Iter2, | ||
class _Sent2, | ||
class _Proj1, | ||
class _Proj2> | ||
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter1 __find_end( | ||
_Iter1 __first1, | ||
_Sent1 __sent1, | ||
_Iter2 __first2, | ||
_Sent2 __sent2, | ||
_Pred& __pred, | ||
_Proj1& __proj1, | ||
_Proj2& __proj2, | ||
bidirectional_iterator_tag, | ||
bidirectional_iterator_tag) { | ||
auto __last1 = _IterOps::next(__first1, __sent1); | ||
auto __last2 = _IterOps::next(__first2, __sent2); | ||
// modeled after search algorithm (in reverse) | ||
if (__first2 == __last2) | ||
return __last1; // Everything matches an empty sequence | ||
_Iter1 __l1 = __last1; | ||
_Iter2 __l2 = __last2; | ||
--__l2; | ||
while (true) { | ||
// Find last element in sequence 1 that matchs *(__last2-1), with a mininum of loop checks | ||
while (true) { | ||
if (__first1 == __l1) // return __last1 if no element matches *__first2 | ||
return __last1; | ||
if (std::__invoke(__pred, std::__invoke(__proj1, *--__l1), std::__invoke(__proj2, *__l2))) | ||
break; | ||
} | ||
// *__l1 matches *__l2, now match elements before here | ||
_Iter1 __m1 = __l1; | ||
_Iter2 __m2 = __l2; | ||
while (true) { | ||
if (__m2 == __first2) // If pattern exhausted, __m1 is the answer (works for 1 element pattern) | ||
return __m1; | ||
if (__m1 == __first1) // Otherwise if source exhaused, pattern not found | ||
return __last1; | ||
|
||
// if there is a mismatch, restart with a new __l1 | ||
if (!std::__invoke(__pred, std::__invoke(__proj1, *--__m1), std::__invoke(__proj2, *--__m2))) | ||
{ | ||
break; | ||
} // else there is a match, check next elements | ||
} | ||
} | ||
} | ||
|
||
template < | ||
class _AlgPolicy, | ||
class _Pred, | ||
class _Iter1, | ||
class _Sent1, | ||
class _Iter2, | ||
class _Sent2, | ||
class _Proj1, | ||
class _Proj2> | ||
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Iter1 __find_end( | ||
_Iter1 __first1, | ||
_Sent1 __sent1, | ||
_Iter2 __first2, | ||
_Sent2 __sent2, | ||
_Pred& __pred, | ||
_Proj1& __proj1, | ||
_Proj2& __proj2, | ||
random_access_iterator_tag, | ||
random_access_iterator_tag) { | ||
typedef typename iterator_traits<_Iter1>::difference_type _D1; | ||
auto __last1 = _IterOps<_AlgPolicy>::next(__first1, __sent1); | ||
auto __last2 = _IterOps<_AlgPolicy>::next(__first2, __sent2); | ||
// Take advantage of knowing source and pattern lengths. Stop short when source is smaller than pattern | ||
auto __len2 = __last2 - __first2; | ||
if (__len2 == 0) | ||
return __last1; | ||
auto __len1 = __last1 - __first1; | ||
if (__len1 < __len2) | ||
return __last1; | ||
const _Iter1 __s = __first1 + _D1(__len2 - 1); // End of pattern match can't go before here | ||
_Iter1 __l1 = __last1; | ||
_Iter2 __l2 = __last2; | ||
--__l2; | ||
while (true) { | ||
while (true) { | ||
if (__s == __l1) | ||
return __last1; | ||
if (std::__invoke(__pred, std::__invoke(__proj1, *--__l1), std::__invoke(__proj2, *__l2))) | ||
break; | ||
} | ||
_Iter1 __m1 = __l1; | ||
_Iter2 __m2 = __l2; | ||
while (true) { | ||
if (__m2 == __first2) | ||
return __m1; | ||
// no need to check range on __m1 because __s guarantees we have enough source | ||
if (!std::__invoke(__pred, std::__invoke(__proj1, *--__m1), std::__invoke(*--__m2))) { | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
|
||
template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate> | ||
_LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 | ||
_ForwardIterator1 __find_end_classic(_ForwardIterator1 __first1, _ForwardIterator1 __last1, | ||
_ForwardIterator2 __first2, _ForwardIterator2 __last2, | ||
_BinaryPredicate& __pred) { | ||
auto __proj = __identity(); | ||
return std::__find_end_impl<_ClassicAlgPolicy>( | ||
__first1, | ||
__last1, | ||
__first2, | ||
__last2, | ||
__pred, | ||
__proj, | ||
__proj, | ||
typename iterator_traits<_ForwardIterator1>::iterator_category(), | ||
typename iterator_traits<_ForwardIterator2>::iterator_category()) | ||
.first; | ||
} | ||
|
||
template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate> | ||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 | ||
_ForwardIterator1 find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1, | ||
_ForwardIterator2 __first2, _ForwardIterator2 __last2, | ||
_BinaryPredicate __pred) { | ||
return std::__find_end_classic(__first1, __last1, __first2, __last2, __pred); | ||
} | ||
|
||
template <class _ForwardIterator1, class _ForwardIterator2> | ||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 | ||
_ForwardIterator1 find_end(_ForwardIterator1 __first1, _ForwardIterator1 __last1, | ||
_ForwardIterator2 __first2, _ForwardIterator2 __last2) { | ||
return std::find_end(__first1, __last1, __first2, __last2, __equal_to()); | ||
} | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
|
||
#endif // _LIBCPP___ALGORITHM_FIND_END_OF_H |
52 changes: 52 additions & 0 deletions
52
app/src/main/cpp/libcxx/include/__algorithm/find_first_of.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// -*- C++ -*- | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCPP___ALGORITHM_FIND_FIRST_OF_H | ||
#define _LIBCPP___ALGORITHM_FIND_FIRST_OF_H | ||
|
||
#include <__algorithm/comp.h> | ||
#include <__config> | ||
#include <__iterator/iterator_traits.h> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
#endif | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate> | ||
_LIBCPP_HIDE_FROM_ABI | ||
_LIBCPP_CONSTEXPR_SINCE_CXX14 _ForwardIterator1 __find_first_of_ce(_ForwardIterator1 __first1, | ||
_ForwardIterator1 __last1, | ||
_ForwardIterator2 __first2, | ||
_ForwardIterator2 __last2, | ||
_BinaryPredicate&& __pred) { | ||
for (; __first1 != __last1; ++__first1) | ||
for (_ForwardIterator2 __j = __first2; __j != __last2; ++__j) | ||
if (__pred(*__first1, *__j)) | ||
return __first1; | ||
return __last1; | ||
} | ||
|
||
template <class _ForwardIterator1, class _ForwardIterator2, class _BinaryPredicate> | ||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 | ||
find_first_of(_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, | ||
_ForwardIterator2 __last2, _BinaryPredicate __pred) { | ||
return _VSTD::__find_first_of_ce(__first1, __last1, __first2, __last2, __pred); | ||
} | ||
|
||
template <class _ForwardIterator1, class _ForwardIterator2> | ||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator1 find_first_of( | ||
_ForwardIterator1 __first1, _ForwardIterator1 __last1, _ForwardIterator2 __first2, _ForwardIterator2 __last2) { | ||
return std::__find_first_of_ce(__first1, __last1, __first2, __last2, __equal_to()); | ||
} | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
|
||
#endif // _LIBCPP___ALGORITHM_FIND_FIRST_OF_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// -*- C++ -*- | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCPP___ALGORITHM_FIND_IF_H | ||
#define _LIBCPP___ALGORITHM_FIND_IF_H | ||
|
||
#include <__config> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
#endif | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
template <class _InputIterator, class _Predicate> | ||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator | ||
find_if(_InputIterator __first, _InputIterator __last, _Predicate __pred) { | ||
for (; __first != __last; ++__first) | ||
if (__pred(*__first)) | ||
break; | ||
return __first; | ||
} | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
|
||
#endif // _LIBCPP___ALGORITHM_FIND_IF_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// -*- C++ -*- | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCPP___ALGORITHM_FIND_IF_NOT_H | ||
#define _LIBCPP___ALGORITHM_FIND_IF_NOT_H | ||
|
||
#include <__config> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
#endif | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
template <class _InputIterator, class _Predicate> | ||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator | ||
find_if_not(_InputIterator __first, _InputIterator __last, _Predicate __pred) { | ||
for (; __first != __last; ++__first) | ||
if (!__pred(*__first)) | ||
break; | ||
return __first; | ||
} | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
|
||
#endif // _LIBCPP___ALGORITHM_FIND_IF_NOT_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// -*- C++ -*- | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCPP___ALGORITHM_FOR_EACH_H | ||
#define _LIBCPP___ALGORITHM_FOR_EACH_H | ||
|
||
#include <__config> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
#endif | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
template <class _InputIterator, class _Function> | ||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _Function for_each(_InputIterator __first, | ||
_InputIterator __last, | ||
_Function __f) { | ||
for (; __first != __last; ++__first) | ||
__f(*__first); | ||
return __f; | ||
} | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
|
||
#endif // _LIBCPP___ALGORITHM_FOR_EACH_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// -*- C++ -*- | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCPP___ALGORITHM_FOR_EACH_N_H | ||
#define _LIBCPP___ALGORITHM_FOR_EACH_N_H | ||
|
||
#include <__config> | ||
#include <__utility/convert_to_integral.h> | ||
#include <type_traits> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
#endif | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
#if _LIBCPP_STD_VER > 14 | ||
|
||
template <class _InputIterator, class _Size, class _Function> | ||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _InputIterator for_each_n(_InputIterator __first, | ||
_Size __orig_n, | ||
_Function __f) { | ||
typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize; | ||
_IntegralSize __n = __orig_n; | ||
while (__n > 0) { | ||
__f(*__first); | ||
++__first; | ||
--__n; | ||
} | ||
return __first; | ||
} | ||
|
||
#endif | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
|
||
#endif // _LIBCPP___ALGORITHM_FOR_EACH_N_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCPP___ALGORITHM_GENERATE_H | ||
#define _LIBCPP___ALGORITHM_GENERATE_H | ||
|
||
#include <__config> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
#endif | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
template <class _ForwardIterator, class _Generator> | ||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 | ||
void | ||
generate(_ForwardIterator __first, _ForwardIterator __last, _Generator __gen) | ||
{ | ||
for (; __first != __last; ++__first) | ||
*__first = __gen(); | ||
} | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
|
||
#endif // _LIBCPP___ALGORITHM_GENERATE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCPP___ALGORITHM_GENERATE_N_H | ||
#define _LIBCPP___ALGORITHM_GENERATE_N_H | ||
|
||
#include <__config> | ||
#include <__utility/convert_to_integral.h> | ||
#include <type_traits> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
#endif | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
template <class _OutputIterator, class _Size, class _Generator> | ||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 | ||
_OutputIterator | ||
generate_n(_OutputIterator __first, _Size __orig_n, _Generator __gen) | ||
{ | ||
typedef decltype(_VSTD::__convert_to_integral(__orig_n)) _IntegralSize; | ||
_IntegralSize __n = __orig_n; | ||
for (; __n > 0; ++__first, (void) --__n) | ||
*__first = __gen(); | ||
return __first; | ||
} | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
|
||
#endif // _LIBCPP___ALGORITHM_GENERATE_N_H |
49 changes: 49 additions & 0 deletions
49
app/src/main/cpp/libcxx/include/__algorithm/half_positive.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCPP___ALGORITHM_HALF_POSITIVE_H | ||
#define _LIBCPP___ALGORITHM_HALF_POSITIVE_H | ||
|
||
#include <__config> | ||
#include <type_traits> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
#endif | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
// Perform division by two quickly for positive integers (llvm.org/PR39129) | ||
|
||
template <typename _Integral> | ||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | ||
typename enable_if | ||
< | ||
is_integral<_Integral>::value, | ||
_Integral | ||
>::type | ||
__half_positive(_Integral __value) | ||
{ | ||
return static_cast<_Integral>(static_cast<__make_unsigned_t<_Integral> >(__value) / 2); | ||
} | ||
|
||
template <typename _Tp> | ||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR | ||
typename enable_if | ||
< | ||
!is_integral<_Tp>::value, | ||
_Tp | ||
>::type | ||
__half_positive(_Tp __value) | ||
{ | ||
return __value / 2; | ||
} | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
|
||
#endif // _LIBCPP___ALGORITHM_HALF_POSITIVE_H |
49 changes: 49 additions & 0 deletions
49
app/src/main/cpp/libcxx/include/__algorithm/in_found_result.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// -*- C++ -*- | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCPP___ALGORITHM_IN_FOUND_RESULT_H | ||
#define _LIBCPP___ALGORITHM_IN_FOUND_RESULT_H | ||
|
||
#include <__concepts/convertible_to.h> | ||
#include <__config> | ||
#include <__utility/move.h> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
#endif | ||
|
||
#if _LIBCPP_STD_VER > 17 | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
namespace ranges { | ||
template <class _InIter1> | ||
struct in_found_result { | ||
_LIBCPP_NO_UNIQUE_ADDRESS _InIter1 in; | ||
bool found; | ||
|
||
template <class _InIter2> | ||
requires convertible_to<const _InIter1&, _InIter2> | ||
_LIBCPP_HIDE_FROM_ABI constexpr operator in_found_result<_InIter2>() const & { | ||
return {in, found}; | ||
} | ||
|
||
template <class _InIter2> | ||
requires convertible_to<_InIter1, _InIter2> | ||
_LIBCPP_HIDE_FROM_ABI constexpr operator in_found_result<_InIter2>() && { | ||
return {std::move(in), found}; | ||
} | ||
}; | ||
} // namespace ranges | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
|
||
#endif // _LIBCPP_STD_VER > 17 | ||
|
||
#endif // _LIBCPP___ALGORITHM_IN_FOUND_RESULT_H |
49 changes: 49 additions & 0 deletions
49
app/src/main/cpp/libcxx/include/__algorithm/in_fun_result.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// -*- C++ -*- | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCPP___ALGORITHM_IN_FUN_RESULT_H | ||
#define _LIBCPP___ALGORITHM_IN_FUN_RESULT_H | ||
|
||
#include <__concepts/convertible_to.h> | ||
#include <__config> | ||
#include <__utility/move.h> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
#endif | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
#if _LIBCPP_STD_VER > 17 | ||
|
||
namespace ranges { | ||
template <class _InIter1, class _Func1> | ||
struct in_fun_result { | ||
_LIBCPP_NO_UNIQUE_ADDRESS _InIter1 in; | ||
_LIBCPP_NO_UNIQUE_ADDRESS _Func1 fun; | ||
|
||
template <class _InIter2, class _Func2> | ||
requires convertible_to<const _InIter1&, _InIter2> && convertible_to<const _Func1&, _Func2> | ||
_LIBCPP_HIDE_FROM_ABI constexpr operator in_fun_result<_InIter2, _Func2>() const & { | ||
return {in, fun}; | ||
} | ||
|
||
template <class _InIter2, class _Func2> | ||
requires convertible_to<_InIter1, _InIter2> && convertible_to<_Func1, _Func2> | ||
_LIBCPP_HIDE_FROM_ABI constexpr operator in_fun_result<_InIter2, _Func2>() && { | ||
return {std::move(in), std::move(fun)}; | ||
} | ||
}; | ||
} // namespace ranges | ||
|
||
#endif // _LIBCPP_STD_VER > 17 | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
|
||
#endif // _LIBCPP___ALGORITHM_IN_FUN_RESULT_H |
56 changes: 56 additions & 0 deletions
56
app/src/main/cpp/libcxx/include/__algorithm/in_in_out_result.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// -*- C++ -*- | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCPP___ALGORITHM_IN_IN_OUT_RESULT_H | ||
#define _LIBCPP___ALGORITHM_IN_IN_OUT_RESULT_H | ||
|
||
#include <__concepts/convertible_to.h> | ||
#include <__config> | ||
#include <__utility/move.h> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
#endif | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
#if _LIBCPP_STD_VER > 17 | ||
|
||
namespace ranges { | ||
|
||
template <class _InIter1, class _InIter2, class _OutIter1> | ||
struct in_in_out_result { | ||
_LIBCPP_NO_UNIQUE_ADDRESS _InIter1 in1; | ||
_LIBCPP_NO_UNIQUE_ADDRESS _InIter2 in2; | ||
_LIBCPP_NO_UNIQUE_ADDRESS _OutIter1 out; | ||
|
||
template <class _InIter3, class _InIter4, class _OutIter2> | ||
requires convertible_to<const _InIter1&, _InIter3> | ||
&& convertible_to<const _InIter2&, _InIter4> && convertible_to<const _OutIter1&, _OutIter2> | ||
_LIBCPP_HIDE_FROM_ABI constexpr | ||
operator in_in_out_result<_InIter3, _InIter4, _OutIter2>() const& { | ||
return {in1, in2, out}; | ||
} | ||
|
||
template <class _InIter3, class _InIter4, class _OutIter2> | ||
requires convertible_to<_InIter1, _InIter3> | ||
&& convertible_to<_InIter2, _InIter4> && convertible_to<_OutIter1, _OutIter2> | ||
_LIBCPP_HIDE_FROM_ABI constexpr | ||
operator in_in_out_result<_InIter3, _InIter4, _OutIter2>() && { | ||
return {std::move(in1), std::move(in2), std::move(out)}; | ||
} | ||
}; | ||
|
||
} // namespace ranges | ||
|
||
#endif // _LIBCPP_STD_VER > 17 | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
|
||
#endif // _LIBCPP___ALGORITHM_IN_IN_OUT_RESULT_H |
53 changes: 53 additions & 0 deletions
53
app/src/main/cpp/libcxx/include/__algorithm/in_in_result.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// -*- C++ -*- | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCPP___ALGORITHM_IN_IN_RESULT_H | ||
#define _LIBCPP___ALGORITHM_IN_IN_RESULT_H | ||
|
||
#include <__concepts/convertible_to.h> | ||
#include <__config> | ||
#include <__utility/move.h> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
#endif | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
#if _LIBCPP_STD_VER > 17 | ||
|
||
namespace ranges { | ||
|
||
template <class _InIter1, class _InIter2> | ||
struct in_in_result { | ||
_LIBCPP_NO_UNIQUE_ADDRESS _InIter1 in1; | ||
_LIBCPP_NO_UNIQUE_ADDRESS _InIter2 in2; | ||
|
||
template <class _InIter3, class _InIter4> | ||
requires convertible_to<const _InIter1&, _InIter3> && convertible_to<const _InIter2&, _InIter4> | ||
_LIBCPP_HIDE_FROM_ABI constexpr | ||
operator in_in_result<_InIter3, _InIter4>() const & { | ||
return {in1, in2}; | ||
} | ||
|
||
template <class _InIter3, class _InIter4> | ||
requires convertible_to<_InIter1, _InIter3> && convertible_to<_InIter2, _InIter4> | ||
_LIBCPP_HIDE_FROM_ABI constexpr | ||
operator in_in_result<_InIter3, _InIter4>() && { | ||
return {std::move(in1), std::move(in2)}; | ||
} | ||
}; | ||
|
||
} // namespace ranges | ||
|
||
#endif // _LIBCPP_STD_VER > 17 | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
|
||
#endif // _LIBCPP___ALGORITHM_IN_IN_RESULT_H |
54 changes: 54 additions & 0 deletions
54
app/src/main/cpp/libcxx/include/__algorithm/in_out_out_result.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// -*- C++ -*- | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCPP___ALGORITHM_IN_OUT_OUT_RESULT_H | ||
#define _LIBCPP___ALGORITHM_IN_OUT_OUT_RESULT_H | ||
|
||
#include <__concepts/convertible_to.h> | ||
#include <__config> | ||
#include <__utility/move.h> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
#endif | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
#if _LIBCPP_STD_VER > 17 | ||
|
||
namespace ranges { | ||
template <class _InIter1, class _OutIter1, class _OutIter2> | ||
struct in_out_out_result { | ||
_LIBCPP_NO_UNIQUE_ADDRESS _InIter1 in; | ||
_LIBCPP_NO_UNIQUE_ADDRESS _OutIter1 out1; | ||
_LIBCPP_NO_UNIQUE_ADDRESS _OutIter2 out2; | ||
|
||
template <class _InIter2, class _OutIter3, class _OutIter4> | ||
requires convertible_to<const _InIter1&, _InIter2> | ||
&& convertible_to<const _OutIter1&, _OutIter3> && convertible_to<const _OutIter2&, _OutIter4> | ||
_LIBCPP_HIDE_FROM_ABI constexpr | ||
operator in_out_out_result<_InIter2, _OutIter3, _OutIter4>() const& { | ||
return {in, out1, out2}; | ||
} | ||
|
||
template <class _InIter2, class _OutIter3, class _OutIter4> | ||
requires convertible_to<_InIter1, _InIter2> | ||
&& convertible_to<_OutIter1, _OutIter3> && convertible_to<_OutIter2, _OutIter4> | ||
_LIBCPP_HIDE_FROM_ABI constexpr | ||
operator in_out_out_result<_InIter2, _OutIter3, _OutIter4>() && { | ||
return {std::move(in), std::move(out1), std::move(out2)}; | ||
} | ||
}; | ||
} // namespace ranges | ||
|
||
#endif // _LIBCPP_STD_VER > 17 | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
|
||
#endif // _LIBCPP___ALGORITHM_IN_OUT_OUT_RESULT_H |
53 changes: 53 additions & 0 deletions
53
app/src/main/cpp/libcxx/include/__algorithm/in_out_result.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// -*- C++ -*- | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCPP___ALGORITHM_IN_OUT_RESULT_H | ||
#define _LIBCPP___ALGORITHM_IN_OUT_RESULT_H | ||
|
||
#include <__concepts/convertible_to.h> | ||
#include <__config> | ||
#include <__utility/move.h> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
#endif | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
#if _LIBCPP_STD_VER > 17 | ||
|
||
namespace ranges { | ||
|
||
template<class _InIter1, class _OutIter1> | ||
struct in_out_result { | ||
_LIBCPP_NO_UNIQUE_ADDRESS _InIter1 in; | ||
_LIBCPP_NO_UNIQUE_ADDRESS _OutIter1 out; | ||
|
||
template <class _InIter2, class _OutIter2> | ||
requires convertible_to<const _InIter1&, _InIter2> && convertible_to<const _OutIter1&, _OutIter2> | ||
_LIBCPP_HIDE_FROM_ABI | ||
constexpr operator in_out_result<_InIter2, _OutIter2>() const & { | ||
return {in, out}; | ||
} | ||
|
||
template <class _InIter2, class _OutIter2> | ||
requires convertible_to<_InIter1, _InIter2> && convertible_to<_OutIter1, _OutIter2> | ||
_LIBCPP_HIDE_FROM_ABI | ||
constexpr operator in_out_result<_InIter2, _OutIter2>() && { | ||
return {std::move(in), std::move(out)}; | ||
} | ||
}; | ||
|
||
} // namespace ranges | ||
|
||
#endif // _LIBCPP_STD_VER > 17 | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
|
||
#endif // _LIBCPP___ALGORITHM_IN_OUT_RESULT_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCPP___ALGORITHM_INCLUDES_H | ||
#define _LIBCPP___ALGORITHM_INCLUDES_H | ||
|
||
#include <__algorithm/comp.h> | ||
#include <__algorithm/comp_ref_type.h> | ||
#include <__config> | ||
#include <__functional/identity.h> | ||
#include <__functional/invoke.h> | ||
#include <__iterator/iterator_traits.h> | ||
#include <__type_traits/is_callable.h> | ||
#include <__utility/move.h> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
#endif | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
template <class _Iter1, class _Sent1, class _Iter2, class _Sent2, class _Comp, class _Proj1, class _Proj2> | ||
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | ||
__includes(_Iter1 __first1, _Sent1 __last1, _Iter2 __first2, _Sent2 __last2, | ||
_Comp&& __comp, _Proj1&& __proj1, _Proj2&& __proj2) { | ||
for (; __first2 != __last2; ++__first1) { | ||
if (__first1 == __last1 || std::__invoke( | ||
__comp, std::__invoke(__proj2, *__first2), std::__invoke(__proj1, *__first1))) | ||
return false; | ||
if (!std::__invoke(__comp, std::__invoke(__proj1, *__first1), std::__invoke(__proj2, *__first2))) | ||
++__first2; | ||
} | ||
return true; | ||
} | ||
|
||
template <class _InputIterator1, class _InputIterator2, class _Compare> | ||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool includes( | ||
_InputIterator1 __first1, | ||
_InputIterator1 __last1, | ||
_InputIterator2 __first2, | ||
_InputIterator2 __last2, | ||
_Compare __comp) { | ||
static_assert(__is_callable<_Compare, decltype(*__first1), decltype(*__first2)>::value, | ||
"Comparator has to be callable"); | ||
|
||
return std::__includes( | ||
std::move(__first1), | ||
std::move(__last1), | ||
std::move(__first2), | ||
std::move(__last2), | ||
static_cast<__comp_ref_type<_Compare> >(__comp), | ||
__identity(), | ||
__identity()); | ||
} | ||
|
||
template <class _InputIterator1, class _InputIterator2> | ||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | ||
includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2) { | ||
return std::includes( | ||
std::move(__first1), | ||
std::move(__last1), | ||
std::move(__first2), | ||
std::move(__last2), | ||
__less<typename iterator_traits<_InputIterator1>::value_type, | ||
typename iterator_traits<_InputIterator2>::value_type>()); | ||
} | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
|
||
#endif // _LIBCPP___ALGORITHM_INCLUDES_H |
257 changes: 257 additions & 0 deletions
257
app/src/main/cpp/libcxx/include/__algorithm/inplace_merge.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,257 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCPP___ALGORITHM_INPLACE_MERGE_H | ||
#define _LIBCPP___ALGORITHM_INPLACE_MERGE_H | ||
|
||
#include <__algorithm/comp.h> | ||
#include <__algorithm/comp_ref_type.h> | ||
#include <__algorithm/iterator_operations.h> | ||
#include <__algorithm/lower_bound.h> | ||
#include <__algorithm/min.h> | ||
#include <__algorithm/move.h> | ||
#include <__algorithm/rotate.h> | ||
#include <__algorithm/upper_bound.h> | ||
#include <__config> | ||
#include <__functional/identity.h> | ||
#include <__iterator/advance.h> | ||
#include <__iterator/distance.h> | ||
#include <__iterator/iterator_traits.h> | ||
#include <__iterator/reverse_iterator.h> | ||
#include <__memory/destruct_n.h> | ||
#include <__memory/temporary_buffer.h> | ||
#include <__memory/unique_ptr.h> | ||
#include <__utility/pair.h> | ||
#include <new> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
#endif | ||
|
||
_LIBCPP_PUSH_MACROS | ||
#include <__undef_macros> | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
template <class _Predicate> | ||
class __invert // invert the sense of a comparison | ||
{ | ||
private: | ||
_Predicate __p_; | ||
public: | ||
_LIBCPP_INLINE_VISIBILITY __invert() {} | ||
|
||
_LIBCPP_INLINE_VISIBILITY | ||
explicit __invert(_Predicate __p) : __p_(__p) {} | ||
|
||
template <class _T1> | ||
_LIBCPP_INLINE_VISIBILITY | ||
bool operator()(const _T1& __x) {return !__p_(__x);} | ||
|
||
template <class _T1, class _T2> | ||
_LIBCPP_INLINE_VISIBILITY | ||
bool operator()(const _T1& __x, const _T2& __y) {return __p_(__y, __x);} | ||
}; | ||
|
||
template <class _AlgPolicy, class _Compare, class _InputIterator1, class _Sent1, | ||
class _InputIterator2, class _Sent2, class _OutputIterator> | ||
_LIBCPP_HIDE_FROM_ABI | ||
void __half_inplace_merge(_InputIterator1 __first1, _Sent1 __last1, | ||
_InputIterator2 __first2, _Sent2 __last2, | ||
_OutputIterator __result, _Compare&& __comp) | ||
{ | ||
for (; __first1 != __last1; ++__result) | ||
{ | ||
if (__first2 == __last2) | ||
{ | ||
std::__move<_AlgPolicy>(__first1, __last1, __result); | ||
return; | ||
} | ||
|
||
if (__comp(*__first2, *__first1)) | ||
{ | ||
*__result = _IterOps<_AlgPolicy>::__iter_move(__first2); | ||
++__first2; | ||
} | ||
else | ||
{ | ||
*__result = _IterOps<_AlgPolicy>::__iter_move(__first1); | ||
++__first1; | ||
} | ||
} | ||
// __first2 through __last2 are already in the right spot. | ||
} | ||
|
||
template <class _AlgPolicy, class _Compare, class _BidirectionalIterator> | ||
_LIBCPP_HIDE_FROM_ABI | ||
void __buffered_inplace_merge( | ||
_BidirectionalIterator __first, | ||
_BidirectionalIterator __middle, | ||
_BidirectionalIterator __last, | ||
_Compare&& __comp, | ||
typename iterator_traits<_BidirectionalIterator>::difference_type __len1, | ||
typename iterator_traits<_BidirectionalIterator>::difference_type __len2, | ||
typename iterator_traits<_BidirectionalIterator>::value_type* __buff) { | ||
typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type; | ||
__destruct_n __d(0); | ||
unique_ptr<value_type, __destruct_n&> __h2(__buff, __d); | ||
if (__len1 <= __len2) | ||
{ | ||
value_type* __p = __buff; | ||
for (_BidirectionalIterator __i = __first; __i != __middle; __d.template __incr<value_type>(), (void) ++__i, (void) ++__p) | ||
::new ((void*)__p) value_type(_IterOps<_AlgPolicy>::__iter_move(__i)); | ||
std::__half_inplace_merge<_AlgPolicy>(__buff, __p, __middle, __last, __first, __comp); | ||
} | ||
else | ||
{ | ||
value_type* __p = __buff; | ||
for (_BidirectionalIterator __i = __middle; __i != __last; __d.template __incr<value_type>(), (void) ++__i, (void) ++__p) | ||
::new ((void*)__p) value_type(_IterOps<_AlgPolicy>::__iter_move(__i)); | ||
typedef __unconstrained_reverse_iterator<_BidirectionalIterator> _RBi; | ||
typedef __unconstrained_reverse_iterator<value_type*> _Rv; | ||
typedef __invert<_Compare> _Inverted; | ||
std::__half_inplace_merge<_AlgPolicy>(_Rv(__p), _Rv(__buff), | ||
_RBi(__middle), _RBi(__first), | ||
_RBi(__last), _Inverted(__comp)); | ||
} | ||
} | ||
|
||
template <class _AlgPolicy, class _Compare, class _BidirectionalIterator> | ||
void __inplace_merge( | ||
_BidirectionalIterator __first, | ||
_BidirectionalIterator __middle, | ||
_BidirectionalIterator __last, | ||
_Compare&& __comp, | ||
typename iterator_traits<_BidirectionalIterator>::difference_type __len1, | ||
typename iterator_traits<_BidirectionalIterator>::difference_type __len2, | ||
typename iterator_traits<_BidirectionalIterator>::value_type* __buff, | ||
ptrdiff_t __buff_size) { | ||
using _Ops = _IterOps<_AlgPolicy>; | ||
|
||
typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type; | ||
while (true) | ||
{ | ||
// if __middle == __last, we're done | ||
if (__len2 == 0) | ||
return; | ||
if (__len1 <= __buff_size || __len2 <= __buff_size) | ||
return std::__buffered_inplace_merge<_AlgPolicy> | ||
(__first, __middle, __last, __comp, __len1, __len2, __buff); | ||
// shrink [__first, __middle) as much as possible (with no moves), returning if it shrinks to 0 | ||
for (; true; ++__first, (void) --__len1) | ||
{ | ||
if (__len1 == 0) | ||
return; | ||
if (__comp(*__middle, *__first)) | ||
break; | ||
} | ||
// __first < __middle < __last | ||
// *__first > *__middle | ||
// partition [__first, __m1) [__m1, __middle) [__middle, __m2) [__m2, __last) such that | ||
// all elements in: | ||
// [__first, __m1) <= [__middle, __m2) | ||
// [__middle, __m2) < [__m1, __middle) | ||
// [__m1, __middle) <= [__m2, __last) | ||
// and __m1 or __m2 is in the middle of its range | ||
_BidirectionalIterator __m1; // "median" of [__first, __middle) | ||
_BidirectionalIterator __m2; // "median" of [__middle, __last) | ||
difference_type __len11; // distance(__first, __m1) | ||
difference_type __len21; // distance(__middle, __m2) | ||
// binary search smaller range | ||
if (__len1 < __len2) | ||
{ // __len >= 1, __len2 >= 2 | ||
__len21 = __len2 / 2; | ||
__m2 = __middle; | ||
_Ops::advance(__m2, __len21); | ||
__m1 = std::__upper_bound<_AlgPolicy>(__first, __middle, *__m2, __comp, std::__identity()); | ||
__len11 = _Ops::distance(__first, __m1); | ||
} | ||
else | ||
{ | ||
if (__len1 == 1) | ||
{ // __len1 >= __len2 && __len2 > 0, therefore __len2 == 1 | ||
// It is known *__first > *__middle | ||
_Ops::iter_swap(__first, __middle); | ||
return; | ||
} | ||
// __len1 >= 2, __len2 >= 1 | ||
__len11 = __len1 / 2; | ||
__m1 = __first; | ||
_Ops::advance(__m1, __len11); | ||
__m2 = std::lower_bound(__middle, __last, *__m1, __comp); | ||
__len21 = _Ops::distance(__middle, __m2); | ||
} | ||
difference_type __len12 = __len1 - __len11; // distance(__m1, __middle) | ||
difference_type __len22 = __len2 - __len21; // distance(__m2, __last) | ||
// [__first, __m1) [__m1, __middle) [__middle, __m2) [__m2, __last) | ||
// swap middle two partitions | ||
__middle = std::__rotate<_AlgPolicy>(__m1, __middle, __m2).first; | ||
// __len12 and __len21 now have swapped meanings | ||
// merge smaller range with recursive call and larger with tail recursion elimination | ||
if (__len11 + __len21 < __len12 + __len22) | ||
{ | ||
std::__inplace_merge<_AlgPolicy>( | ||
__first, __m1, __middle, __comp, __len11, __len21, __buff, __buff_size); | ||
__first = __middle; | ||
__middle = __m2; | ||
__len1 = __len12; | ||
__len2 = __len22; | ||
} | ||
else | ||
{ | ||
std::__inplace_merge<_AlgPolicy>( | ||
__middle, __m2, __last, __comp, __len12, __len22, __buff, __buff_size); | ||
__last = __middle; | ||
__middle = __m1; | ||
__len1 = __len11; | ||
__len2 = __len21; | ||
} | ||
} | ||
} | ||
|
||
template <class _AlgPolicy, class _BidirectionalIterator, class _Compare> | ||
_LIBCPP_HIDE_FROM_ABI | ||
void | ||
__inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, | ||
_Compare&& __comp) | ||
{ | ||
typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type; | ||
typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type; | ||
difference_type __len1 = _IterOps<_AlgPolicy>::distance(__first, __middle); | ||
difference_type __len2 = _IterOps<_AlgPolicy>::distance(__middle, __last); | ||
difference_type __buf_size = _VSTD::min(__len1, __len2); | ||
// TODO: Remove the use of std::get_temporary_buffer | ||
_LIBCPP_SUPPRESS_DEPRECATED_PUSH | ||
pair<value_type*, ptrdiff_t> __buf = _VSTD::get_temporary_buffer<value_type>(__buf_size); | ||
_LIBCPP_SUPPRESS_DEPRECATED_POP | ||
unique_ptr<value_type, __return_temporary_buffer> __h(__buf.first); | ||
return std::__inplace_merge<_AlgPolicy>( | ||
std::move(__first), std::move(__middle), std::move(__last), __comp, __len1, __len2, __buf.first, __buf.second); | ||
} | ||
|
||
template <class _BidirectionalIterator, class _Compare> | ||
inline _LIBCPP_HIDE_FROM_ABI void inplace_merge( | ||
_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last, _Compare __comp) { | ||
std::__inplace_merge<_ClassicAlgPolicy>( | ||
std::move(__first), std::move(__middle), std::move(__last), static_cast<__comp_ref_type<_Compare> >(__comp)); | ||
} | ||
|
||
template <class _BidirectionalIterator> | ||
inline _LIBCPP_HIDE_FROM_ABI | ||
void | ||
inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _BidirectionalIterator __last) | ||
{ | ||
std::inplace_merge(std::move(__first), std::move(__middle), std::move(__last), | ||
__less<typename iterator_traits<_BidirectionalIterator>::value_type>()); | ||
} | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
|
||
_LIBCPP_POP_MACROS | ||
|
||
#endif // _LIBCPP___ALGORITHM_INPLACE_MERGE_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCPP___ALGORITHM_IS_HEAP_H | ||
#define _LIBCPP___ALGORITHM_IS_HEAP_H | ||
|
||
#include <__algorithm/comp.h> | ||
#include <__algorithm/comp_ref_type.h> | ||
#include <__algorithm/is_heap_until.h> | ||
#include <__config> | ||
#include <__iterator/iterator_traits.h> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
#endif | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
template <class _RandomAccessIterator, class _Compare> | ||
_LIBCPP_NODISCARD_EXT inline | ||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 | ||
bool | ||
is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) | ||
{ | ||
return std::__is_heap_until(__first, __last, static_cast<__comp_ref_type<_Compare> >(__comp)) == __last; | ||
} | ||
|
||
template<class _RandomAccessIterator> | ||
_LIBCPP_NODISCARD_EXT inline | ||
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 | ||
bool | ||
is_heap(_RandomAccessIterator __first, _RandomAccessIterator __last) | ||
{ | ||
return _VSTD::is_heap(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>()); | ||
} | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
|
||
#endif // _LIBCPP___ALGORITHM_IS_HEAP_H |
66 changes: 66 additions & 0 deletions
66
app/src/main/cpp/libcxx/include/__algorithm/is_heap_until.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCPP___ALGORITHM_IS_HEAP_UNTIL_H | ||
#define _LIBCPP___ALGORITHM_IS_HEAP_UNTIL_H | ||
|
||
#include <__algorithm/comp.h> | ||
#include <__algorithm/comp_ref_type.h> | ||
#include <__config> | ||
#include <__iterator/iterator_traits.h> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
#endif | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
template <class _Compare, class _RandomAccessIterator> | ||
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _RandomAccessIterator | ||
__is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare&& __comp) | ||
{ | ||
typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type; | ||
difference_type __len = __last - __first; | ||
difference_type __p = 0; | ||
difference_type __c = 1; | ||
_RandomAccessIterator __pp = __first; | ||
while (__c < __len) | ||
{ | ||
_RandomAccessIterator __cp = __first + __c; | ||
if (__comp(*__pp, *__cp)) | ||
return __cp; | ||
++__c; | ||
++__cp; | ||
if (__c == __len) | ||
return __last; | ||
if (__comp(*__pp, *__cp)) | ||
return __cp; | ||
++__p; | ||
++__pp; | ||
__c = 2 * __p + 1; | ||
} | ||
return __last; | ||
} | ||
|
||
template <class _RandomAccessIterator, class _Compare> | ||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _RandomAccessIterator | ||
is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) | ||
{ | ||
return std::__is_heap_until(__first, __last, static_cast<__comp_ref_type<_Compare> >(__comp)); | ||
} | ||
|
||
template<class _RandomAccessIterator> | ||
_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _RandomAccessIterator | ||
is_heap_until(_RandomAccessIterator __first, _RandomAccessIterator __last) | ||
{ | ||
return _VSTD::__is_heap_until(__first, __last, __less<typename iterator_traits<_RandomAccessIterator>::value_type>()); | ||
} | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
|
||
#endif // _LIBCPP___ALGORITHM_IS_HEAP_UNTIL_H |
38 changes: 38 additions & 0 deletions
38
app/src/main/cpp/libcxx/include/__algorithm/is_partitioned.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCPP___ALGORITHM_IS_PARTITIONED_H | ||
#define _LIBCPP___ALGORITHM_IS_PARTITIONED_H | ||
|
||
#include <__config> | ||
|
||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) | ||
# pragma GCC system_header | ||
#endif | ||
|
||
_LIBCPP_BEGIN_NAMESPACE_STD | ||
|
||
template <class _InputIterator, class _Predicate> | ||
_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool | ||
is_partitioned(_InputIterator __first, _InputIterator __last, _Predicate __pred) | ||
{ | ||
for (; __first != __last; ++__first) | ||
if (!__pred(*__first)) | ||
break; | ||
if ( __first == __last ) | ||
return true; | ||
++__first; | ||
for (; __first != __last; ++__first) | ||
if (__pred(*__first)) | ||
return false; | ||
return true; | ||
} | ||
|
||
_LIBCPP_END_NAMESPACE_STD | ||
|
||
#endif // _LIBCPP___ALGORITHM_IS_PARTITIONED_H |
Oops, something went wrong.