1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/stdapis/stlportv5/stl/_numeric.c Wed Mar 31 12:27:01 2010 +0100
1.3 @@ -0,0 +1,104 @@
1.4 +/*
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) 1997
1.14 + * Moscow Center for SPARC Technology
1.15 + *
1.16 + * Copyright (c) 1999
1.17 + * Boris Fomitchev
1.18 + *
1.19 + * This material is provided "as is", with absolutely no warranty expressed
1.20 + * or implied. Any use is at your own risk.
1.21 + *
1.22 + * Permission to use or copy this software for any purpose is hereby granted
1.23 + * without fee, provided the above notices are retained on all copies.
1.24 + * Permission to modify the code and to distribute modified code is granted,
1.25 + * provided the above notices are retained, and a notice that the code was
1.26 + * modified is included with the above copyright notice.
1.27 + *
1.28 + */
1.29 +#ifndef _STLP_NUMERIC_C
1.30 +#define _STLP_NUMERIC_C
1.31 +
1.32 +#ifndef _STLP_INTERNAL_NUMERIC_H
1.33 +# include <stl/_numeric.h>
1.34 +#endif
1.35 +
1.36 +_STLP_BEGIN_NAMESPACE
1.37 +
1.38 +template <class _InputIterator, class _OutputIterator, class _Tp,
1.39 + class _BinaryOperation>
1.40 +_OutputIterator
1.41 +__partial_sum(_InputIterator __first, _InputIterator __last,
1.42 + _OutputIterator __result, _Tp*, _BinaryOperation __binary_op)
1.43 +{
1.44 + _STLP_DEBUG_CHECK(__check_range(__first, __last))
1.45 + if (__first == __last) return __result;
1.46 + *__result = *__first;
1.47 +
1.48 + _Tp __val = *__first;
1.49 + while (++__first != __last) {
1.50 + __val = __binary_op(__val, *__first);
1.51 + *++__result = __val;
1.52 + }
1.53 + return ++__result;
1.54 +}
1.55 +
1.56 +template <class _InputIterator, class _OutputIterator, class _Tp,
1.57 + class _BinaryOperation>
1.58 +_OutputIterator
1.59 +__adjacent_difference(_InputIterator __first, _InputIterator __last,
1.60 + _OutputIterator __result, _Tp*,
1.61 + _BinaryOperation __binary_op) {
1.62 + _STLP_DEBUG_CHECK(__check_range(__first, __last))
1.63 + if (__first == __last) return __result;
1.64 + *__result = *__first;
1.65 + _Tp __val = *__first;
1.66 + while (++__first != __last) {
1.67 + _Tp __tmp = *__first;
1.68 + *++__result = __binary_op(__tmp, __val);
1.69 + __val = __tmp;
1.70 + }
1.71 + return ++__result;
1.72 +}
1.73 +
1.74 +
1.75 +template <class _Tp, class _Integer, class _MonoidOperation>
1.76 +_Tp __power(_Tp __x, _Integer __n, _MonoidOperation __opr)
1.77 +{
1.78 + _STLP_MPWFIX_TRY
1.79 + if (__n == 0)
1.80 + return __identity_element(__opr);
1.81 + else {
1.82 + while ((__n & 1) == 0) {
1.83 + __n >>= 1;
1.84 + __x = __opr(__x, __x);
1.85 + }
1.86 + _Tp __result = __x;
1.87 + _STLP_MPWFIX_TRY
1.88 + __n >>= 1;
1.89 + while (__n != 0) {
1.90 + __x = __opr(__x, __x);
1.91 + if ((__n & 1) != 0)
1.92 + __result = __opr(__result, __x);
1.93 + __n >>= 1;
1.94 + }
1.95 + return __result;
1.96 + _STLP_MPWFIX_CATCH
1.97 + }
1.98 + _STLP_MPWFIX_CATCH_ACTION(__x = _Tp())
1.99 +}
1.100 +
1.101 +_STLP_END_NAMESPACE
1.102 +
1.103 +#endif /* _STLP_NUMERIC_C */
1.104 +
1.105 +// Local Variables:
1.106 +// mode:C++
1.107 +// End: