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