Twilight Princess
Decompilation of The Legend of Zelda: Twilight Princess
Loading...
Searching...
No Matches
algorithm.h
Go to the documentation of this file.
1#ifndef MSL_ALGORITHM_H_
2#define MSL_ALGORITHM_H_
3
4#include <string.h>
5#include <iterator.h>
6
7namespace std {
8template <class ForwardIterator, class T>
10 typedef typename iterator_traits<ForwardIterator>::difference_type difference_type;
11 difference_type len = std::distance(first, last);
12
13 while (len > 0) {
14 ForwardIterator i = first;
15 difference_type step = len / 2;
16 std::advance(i, step);
17
18 if (*i < val) {
19 first = ++i;
20 len -= step + 1;
21 } else {
22 len = step;
23 }
24 }
25
26 return first;
27}
28
29template <class ForwardIterator, class T>
31
32template<class InputIt, class UnaryPredicate>
34
35/*
36template<class OutputIt, class Size, int A2>
37struct __fill_n {
38 OutputIt fill_n(OutputIt first, Size count, const unsigned long& value);
39};
40
41template<>
42unsigned long* __fill_n<unsigned long, long, 0>::fill_n(unsigned long* first, long count, const unsigned long& value) {
43 for (; count > 0; count--) {
44 *first++ = value;
45 }
46 return first;
47}
48
49template<class OutputIt, class Size, class T>
50OutputIt fill_n(OutputIt first, Size count, const T& value) {
51 return __fill_n::fill_n(first, count, value);
52}
53
54
55template<class ForwardIt, class T>
56void __fill(ForwardIt first, ForwardIt last, const T& value, std::random_access_iterator_tag param_3) {
57 fill_n(first, last - first, value);
58}
59*/
60
61template<class ForwardIt, class T>
62inline void fill(ForwardIt first, ForwardIt last, const T& value) {
63 for (; first != last; ++first){
64 *first = value;
65 }
66}
67
68template<class InputIt, class OutputIt>
69inline OutputIt copy(InputIt first, InputIt last,
71 for (; first < last; ++first, ++d_first) {
72 *d_first = *first;
73 }
74 return d_first;
75}
76
77template <class BidirectionalIterator1, class BidirectionalIterator2>
79 while (last != first)
80 *--result = *--last;
81 return result;
82}
83
84template <class T, bool A>
86{
87 static T* copy_backward(T* first, T* last, T* result)
88 {
89 while (last > first)
90 *--result = *--last;
91 return result;
92 }
93};
94
95template <class T>
97{
98 static T* copy_backward(T* first, T* last, T* result)
99 {
100#ifdef DEBUG
101 size_t n = static_cast<size_t>(last - first);
102 result -= n;
103 memmove(result, first, n*sizeof(T));
104 return result;
105#else
106 while (last > first)
107 *--result = *--last;
108 return result;
109#endif
110 }
111};
112
113template <class T>
114inline T* copy_backward(T* first, T* last, T* result) {
115 return __copy_backward<T, true>::copy_backward(first, last, result);
116}
117
118} // namespace std
119
120#endif
T cLib_calcTimer(T *value)
Definition c_lib.h:79
p
Definition e_acos.c:98
n
Definition e_fmod.c:112
int i
Definition e_pow.c:165
static const double T[]
Definition k_tan.c:106
Definition d_a_e_wb.cpp:12
iterator_traits< InputIterator >::difference_type distance(InputIterator first, InputIterator last)
Definition iterator.h:80
OutputIt copy(InputIt first, InputIt last, OutputIt d_first)
Definition algorithm.h:69
void lower_bound()
void advance(InputIterator &i, Distance n)
Definition iterator.h:51
BidirectionalIterator2 copy_backward(BidirectionalIterator1 first, BidirectionalIterator1 last, BidirectionalIterator2 result)
Definition algorithm.h:78
void find_if()
void fill(ForwardIt first, ForwardIt last, const T &value)
Definition algorithm.h:62
void upper_bound()
void * memmove(void *dst, const void *src, size_t n)
Definition mem.c:4
static T * copy_backward(T *first, T *last, T *result)
Definition algorithm.h:98
Definition algorithm.h:86
static T * copy_backward(T *first, T *last, T *result)
Definition algorithm.h:87
Iterator::difference_type difference_type
Definition iterator.h:13