1*58b9f456SAndroid Build Coastguard Worker //===----------------------- algorithm.cpp --------------------------------===//
2*58b9f456SAndroid Build Coastguard Worker //
3*58b9f456SAndroid Build Coastguard Worker // The LLVM Compiler Infrastructure
4*58b9f456SAndroid Build Coastguard Worker //
5*58b9f456SAndroid Build Coastguard Worker // This file is dual licensed under the MIT and the University of Illinois Open
6*58b9f456SAndroid Build Coastguard Worker // Source Licenses. See LICENSE.TXT for details.
7*58b9f456SAndroid Build Coastguard Worker //
8*58b9f456SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
9*58b9f456SAndroid Build Coastguard Worker
10*58b9f456SAndroid Build Coastguard Worker #include "algorithm"
11*58b9f456SAndroid Build Coastguard Worker #include "random"
12*58b9f456SAndroid Build Coastguard Worker #include "mutex"
13*58b9f456SAndroid Build Coastguard Worker
14*58b9f456SAndroid Build Coastguard Worker _LIBCPP_BEGIN_NAMESPACE_STD
15*58b9f456SAndroid Build Coastguard Worker
16*58b9f456SAndroid Build Coastguard Worker template void __sort<__less<char>&, char*>(char*, char*, __less<char>&);
17*58b9f456SAndroid Build Coastguard Worker template void __sort<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&);
18*58b9f456SAndroid Build Coastguard Worker template void __sort<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&);
19*58b9f456SAndroid Build Coastguard Worker template void __sort<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&);
20*58b9f456SAndroid Build Coastguard Worker template void __sort<__less<short>&, short*>(short*, short*, __less<short>&);
21*58b9f456SAndroid Build Coastguard Worker template void __sort<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&);
22*58b9f456SAndroid Build Coastguard Worker template void __sort<__less<int>&, int*>(int*, int*, __less<int>&);
23*58b9f456SAndroid Build Coastguard Worker template void __sort<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&);
24*58b9f456SAndroid Build Coastguard Worker template void __sort<__less<long>&, long*>(long*, long*, __less<long>&);
25*58b9f456SAndroid Build Coastguard Worker template void __sort<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&);
26*58b9f456SAndroid Build Coastguard Worker template void __sort<__less<long long>&, long long*>(long long*, long long*, __less<long long>&);
27*58b9f456SAndroid Build Coastguard Worker template void __sort<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&);
28*58b9f456SAndroid Build Coastguard Worker template void __sort<__less<float>&, float*>(float*, float*, __less<float>&);
29*58b9f456SAndroid Build Coastguard Worker template void __sort<__less<double>&, double*>(double*, double*, __less<double>&);
30*58b9f456SAndroid Build Coastguard Worker template void __sort<__less<long double>&, long double*>(long double*, long double*, __less<long double>&);
31*58b9f456SAndroid Build Coastguard Worker
32*58b9f456SAndroid Build Coastguard Worker template bool __insertion_sort_incomplete<__less<char>&, char*>(char*, char*, __less<char>&);
33*58b9f456SAndroid Build Coastguard Worker template bool __insertion_sort_incomplete<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&);
34*58b9f456SAndroid Build Coastguard Worker template bool __insertion_sort_incomplete<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&);
35*58b9f456SAndroid Build Coastguard Worker template bool __insertion_sort_incomplete<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&);
36*58b9f456SAndroid Build Coastguard Worker template bool __insertion_sort_incomplete<__less<short>&, short*>(short*, short*, __less<short>&);
37*58b9f456SAndroid Build Coastguard Worker template bool __insertion_sort_incomplete<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&);
38*58b9f456SAndroid Build Coastguard Worker template bool __insertion_sort_incomplete<__less<int>&, int*>(int*, int*, __less<int>&);
39*58b9f456SAndroid Build Coastguard Worker template bool __insertion_sort_incomplete<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&);
40*58b9f456SAndroid Build Coastguard Worker template bool __insertion_sort_incomplete<__less<long>&, long*>(long*, long*, __less<long>&);
41*58b9f456SAndroid Build Coastguard Worker template bool __insertion_sort_incomplete<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&);
42*58b9f456SAndroid Build Coastguard Worker template bool __insertion_sort_incomplete<__less<long long>&, long long*>(long long*, long long*, __less<long long>&);
43*58b9f456SAndroid Build Coastguard Worker template bool __insertion_sort_incomplete<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&);
44*58b9f456SAndroid Build Coastguard Worker template bool __insertion_sort_incomplete<__less<float>&, float*>(float*, float*, __less<float>&);
45*58b9f456SAndroid Build Coastguard Worker template bool __insertion_sort_incomplete<__less<double>&, double*>(double*, double*, __less<double>&);
46*58b9f456SAndroid Build Coastguard Worker template bool __insertion_sort_incomplete<__less<long double>&, long double*>(long double*, long double*, __less<long double>&);
47*58b9f456SAndroid Build Coastguard Worker
48*58b9f456SAndroid Build Coastguard Worker template unsigned __sort5<__less<long double>&, long double*>(long double*, long double*, long double*, long double*, long double*, __less<long double>&);
49*58b9f456SAndroid Build Coastguard Worker
50*58b9f456SAndroid Build Coastguard Worker #ifndef _LIBCPP_HAS_NO_THREADS
51*58b9f456SAndroid Build Coastguard Worker _LIBCPP_SAFE_STATIC static __libcpp_mutex_t __rs_mut = _LIBCPP_MUTEX_INITIALIZER;
52*58b9f456SAndroid Build Coastguard Worker #endif
53*58b9f456SAndroid Build Coastguard Worker unsigned __rs_default::__c_ = 0;
54*58b9f456SAndroid Build Coastguard Worker
__rs_default()55*58b9f456SAndroid Build Coastguard Worker __rs_default::__rs_default()
56*58b9f456SAndroid Build Coastguard Worker {
57*58b9f456SAndroid Build Coastguard Worker #ifndef _LIBCPP_HAS_NO_THREADS
58*58b9f456SAndroid Build Coastguard Worker __libcpp_mutex_lock(&__rs_mut);
59*58b9f456SAndroid Build Coastguard Worker #endif
60*58b9f456SAndroid Build Coastguard Worker __c_ = 1;
61*58b9f456SAndroid Build Coastguard Worker }
62*58b9f456SAndroid Build Coastguard Worker
__rs_default(const __rs_default &)63*58b9f456SAndroid Build Coastguard Worker __rs_default::__rs_default(const __rs_default&)
64*58b9f456SAndroid Build Coastguard Worker {
65*58b9f456SAndroid Build Coastguard Worker ++__c_;
66*58b9f456SAndroid Build Coastguard Worker }
67*58b9f456SAndroid Build Coastguard Worker
~__rs_default()68*58b9f456SAndroid Build Coastguard Worker __rs_default::~__rs_default()
69*58b9f456SAndroid Build Coastguard Worker {
70*58b9f456SAndroid Build Coastguard Worker #ifndef _LIBCPP_HAS_NO_THREADS
71*58b9f456SAndroid Build Coastguard Worker if (--__c_ == 0)
72*58b9f456SAndroid Build Coastguard Worker __libcpp_mutex_unlock(&__rs_mut);
73*58b9f456SAndroid Build Coastguard Worker #else
74*58b9f456SAndroid Build Coastguard Worker --__c_;
75*58b9f456SAndroid Build Coastguard Worker #endif
76*58b9f456SAndroid Build Coastguard Worker }
77*58b9f456SAndroid Build Coastguard Worker
78*58b9f456SAndroid Build Coastguard Worker __rs_default::result_type
operator ()()79*58b9f456SAndroid Build Coastguard Worker __rs_default::operator()()
80*58b9f456SAndroid Build Coastguard Worker {
81*58b9f456SAndroid Build Coastguard Worker static mt19937 __rs_g;
82*58b9f456SAndroid Build Coastguard Worker return __rs_g();
83*58b9f456SAndroid Build Coastguard Worker }
84*58b9f456SAndroid Build Coastguard Worker
85*58b9f456SAndroid Build Coastguard Worker __rs_default
__rs_get()86*58b9f456SAndroid Build Coastguard Worker __rs_get()
87*58b9f456SAndroid Build Coastguard Worker {
88*58b9f456SAndroid Build Coastguard Worker return __rs_default();
89*58b9f456SAndroid Build Coastguard Worker }
90*58b9f456SAndroid Build Coastguard Worker
91*58b9f456SAndroid Build Coastguard Worker _LIBCPP_END_NAMESPACE_STD
92