1.1 --- a/epoc32/include/stdapis/stlport/stl/_numeric.h Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/stdapis/stlport/stl/_numeric.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,190 @@
1.4 -_numeric.h
1.5 +/*
1.6 + *
1.7 + * Copyright (c) 1994
1.8 + * Hewlett-Packard Company
1.9 + *
1.10 + * Copyright (c) 1996,1997
1.11 + * Silicon Graphics Computer Systems, Inc.
1.12 + *
1.13 + * Copyright (c) 1999
1.14 + * Boris Fomitchev
1.15 + *
1.16 + * This material is provided "as is", with absolutely no warranty expressed
1.17 + * or implied. Any use is at your own risk.
1.18 + *
1.19 + * Permission to use or copy this software for any purpose is hereby granted
1.20 + * without fee, provided the above notices are retained on all copies.
1.21 + * Permission to modify the code and to distribute modified code is granted,
1.22 + * provided the above notices are retained, and a notice that the code was
1.23 + * modified is included with the above copyright notice.
1.24 + *
1.25 + */
1.26 +
1.27 +/* NOTE: This is an internal header file, included by other STL headers.
1.28 + * You should not attempt to use it directly.
1.29 + */
1.30 +
1.31 +
1.32 +#ifndef _STLP_INTERNAL_NUMERIC_H
1.33 +#define _STLP_INTERNAL_NUMERIC_H
1.34 +
1.35 +#ifndef _STLP_INTERNAL_FUNCTION_H
1.36 +# include <stl/_function_base.h>
1.37 +#endif
1.38 +
1.39 +#ifndef _STLP_INTERNAL_ITERATOR_BASE_H
1.40 +# include <stl/_iterator_base.h>
1.41 +#endif
1.42 +
1.43 +_STLP_BEGIN_NAMESPACE
1.44 +
1.45 +template <class _InputIterator, class _Tp>
1.46 +_STLP_INLINE_LOOP
1.47 +_Tp accumulate(_InputIterator __first, _InputIterator __last, _Tp _Init)
1.48 +{
1.49 + _STLP_DEBUG_CHECK(__check_range(__first, __last))
1.50 + for ( ; __first != __last; ++__first)
1.51 +#ifndef __SYMBIAN32__
1.52 + _Init = _Init + *__first;
1.53 +#else
1.54 + _Init += *__first;
1.55 +#endif
1.56 + return _Init;
1.57 +}
1.58 +
1.59 +template <class _InputIterator, class _Tp, class _BinaryOperation>
1.60 +_STLP_INLINE_LOOP
1.61 +_Tp accumulate(_InputIterator __first, _InputIterator __last, _Tp _Init,
1.62 + _BinaryOperation __binary_op)
1.63 +{
1.64 + _STLP_DEBUG_CHECK(__check_range(__first, __last))
1.65 + for ( ; __first != __last; ++__first)
1.66 + _Init = __binary_op(_Init, *__first);
1.67 + return _Init;
1.68 +}
1.69 +
1.70 +template <class _InputIterator1, class _InputIterator2, class _Tp>
1.71 +_STLP_INLINE_LOOP
1.72 +_Tp inner_product(_InputIterator1 __first1, _InputIterator1 __last1,
1.73 + _InputIterator2 __first2, _Tp _Init)
1.74 +{
1.75 + _STLP_DEBUG_CHECK(__check_range(__first1, __last1))
1.76 + for ( ; __first1 != __last1; ++__first1, ++__first2)
1.77 + _Init = _Init + (*__first1 * *__first2);
1.78 + return _Init;
1.79 +}
1.80 +
1.81 +template <class _InputIterator1, class _InputIterator2, class _Tp,
1.82 + class _BinaryOperation1, class _BinaryOperation2>
1.83 +_STLP_INLINE_LOOP
1.84 +_Tp inner_product(_InputIterator1 __first1, _InputIterator1 __last1,
1.85 + _InputIterator2 __first2, _Tp _Init,
1.86 + _BinaryOperation1 __binary_op1,
1.87 + _BinaryOperation2 __binary_op2)
1.88 +{
1.89 + _STLP_DEBUG_CHECK(__check_range(__first1, __last1))
1.90 + for ( ; __first1 != __last1; ++__first1, ++__first2)
1.91 + _Init = __binary_op1(_Init, __binary_op2(*__first1, *__first2));
1.92 + return _Init;
1.93 +}
1.94 +
1.95 +template <class _InputIterator, class _OutputIterator, class _Tp,
1.96 + class _BinaryOperation>
1.97 +_OutputIterator
1.98 +__partial_sum(_InputIterator __first, _InputIterator __last,
1.99 + _OutputIterator __result, _Tp*, _BinaryOperation __binary_op);
1.100 +
1.101 +
1.102 +template <class _InputIterator, class _OutputIterator>
1.103 +inline _OutputIterator
1.104 +partial_sum(_InputIterator __first, _InputIterator __last,
1.105 + _OutputIterator __result) {
1.106 + return __partial_sum(__first, __last, __result, _STLP_VALUE_TYPE(__first, _InputIterator),
1.107 + __plus(_STLP_VALUE_TYPE(__first, _InputIterator)));
1.108 +}
1.109 +
1.110 +template <class _InputIterator, class _OutputIterator, class _BinaryOperation>
1.111 +inline _OutputIterator
1.112 +partial_sum(_InputIterator __first, _InputIterator __last,
1.113 + _OutputIterator __result, _BinaryOperation __binary_op) {
1.114 + return __partial_sum(__first, __last, __result, _STLP_VALUE_TYPE(__first, _InputIterator),
1.115 + __binary_op);
1.116 +}
1.117 +
1.118 +
1.119 +template <class _InputIterator, class _OutputIterator, class _Tp,
1.120 + class _BinaryOperation>
1.121 +_OutputIterator
1.122 +__adjacent_difference(_InputIterator __first, _InputIterator __last,
1.123 + _OutputIterator __result, _Tp*,
1.124 + _BinaryOperation __binary_op);
1.125 +
1.126 +template <class _InputIterator, class _OutputIterator>
1.127 +inline _OutputIterator
1.128 +adjacent_difference(_InputIterator __first,
1.129 + _InputIterator __last, _OutputIterator __result) {
1.130 + return __adjacent_difference(__first, __last, __result,
1.131 + _STLP_VALUE_TYPE(__first, _InputIterator),
1.132 + __minus(_STLP_VALUE_TYPE(__first, _InputIterator)));
1.133 +}
1.134 +
1.135 +template <class _InputIterator, class _OutputIterator, class _BinaryOperation>
1.136 +_OutputIterator
1.137 +adjacent_difference(_InputIterator __first, _InputIterator __last,
1.138 + _OutputIterator __result, _BinaryOperation __binary_op) {
1.139 + return __adjacent_difference(__first, __last, __result,
1.140 + _STLP_VALUE_TYPE(__first, _InputIterator),
1.141 + __binary_op);
1.142 +}
1.143 +
1.144 +template <class _Tp, class _Integer, class _MonoidOperation>
1.145 +_Tp __power(_Tp __x, _Integer __n, _MonoidOperation __opr);
1.146 +
1.147 +# ifndef _STLP_NO_EXTENSIONS
1.148 +
1.149 +// Returns __x ** __n, where __n >= 0. _Note that "multiplication"
1.150 +// is required to be associative, but not necessarily commutative.
1.151 +
1.152 +template <class _Tp, class _Integer>
1.153 +inline _Tp __power(_Tp __x, _Integer __n)
1.154 +{
1.155 + return __power(__x, __n, multiplies<_Tp>());
1.156 +}
1.157 +
1.158 +// Alias for the internal name __power. Note that power is an extension,
1.159 +// not part of the C++ standard.
1.160 +template <class _Tp, class _Integer, class _MonoidOperation>
1.161 +inline _Tp power(_Tp __x, _Integer __n, _MonoidOperation __opr) {
1.162 + return __power(__x, __n, __opr);
1.163 +}
1.164 +
1.165 +
1.166 +template <class _Tp, class _Integer>
1.167 +inline _Tp power(_Tp __x, _Integer __n) {
1.168 + return __power(__x, __n, multiplies<_Tp>());
1.169 +}
1.170 +
1.171 +// iota is not part of the C++ standard. It is an extension.
1.172 +
1.173 +template <class _ForwardIterator, class _Tp>
1.174 +_STLP_INLINE_LOOP
1.175 +void
1.176 +iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __val)
1.177 +{
1.178 + _STLP_DEBUG_CHECK(__check_range(__first, __last))
1.179 + while (__first != __last)
1.180 + *__first++ = __val++;
1.181 +}
1.182 +# endif
1.183 +
1.184 +_STLP_END_NAMESPACE
1.185 +
1.186 +# if !defined (_STLP_LINK_TIME_INSTANTIATION)
1.187 +# include <stl/_numeric.c>
1.188 +# endif
1.189 +
1.190 +#endif /* _STLP_INTERNAL_NUMERIC_H */
1.191 +
1.192 +// Local Variables:
1.193 +// mode:C++
1.194 +// End: