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