epoc32/include/stdapis/stlportv5/stl/_numeric.h
branchSymbian2
changeset 3 e1b950c65cb4
parent 2 2fe1408b6811
child 4 837f303aceeb
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/stdapis/stlportv5/stl/_numeric.h	Wed Mar 31 12:27:01 2010 +0100
     1.3 @@ -0,0 +1,190 @@
     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 +
    1.31 +#ifndef _STLP_INTERNAL_NUMERIC_H
    1.32 +#define _STLP_INTERNAL_NUMERIC_H
    1.33 +
    1.34 +#ifndef _STLP_INTERNAL_FUNCTION_H
    1.35 +# include <stl/_function_base.h>
    1.36 +#endif
    1.37 +
    1.38 +#ifndef _STLP_INTERNAL_ITERATOR_BASE_H
    1.39 +# include <stl/_iterator_base.h>
    1.40 +#endif
    1.41 +
    1.42 +_STLP_BEGIN_NAMESPACE
    1.43 +
    1.44 +template <class _InputIterator, class _Tp>
    1.45 +_STLP_INLINE_LOOP
    1.46 +_Tp accumulate(_InputIterator __first, _InputIterator __last, _Tp _Init)
    1.47 +{
    1.48 +  _STLP_DEBUG_CHECK(__check_range(__first, __last))
    1.49 +  for ( ; __first != __last; ++__first)
    1.50 +#ifndef 	__SYMBIAN32__  	
    1.51 +    _Init = _Init + *__first;
    1.52 +#else
    1.53 +	    _Init +=  *__first;
    1.54 +#endif
    1.55 +  return _Init;
    1.56 +}
    1.57 +
    1.58 +template <class _InputIterator, class _Tp, class _BinaryOperation>
    1.59 +_STLP_INLINE_LOOP
    1.60 +_Tp accumulate(_InputIterator __first, _InputIterator __last, _Tp _Init,
    1.61 +               _BinaryOperation __binary_op)
    1.62 +{
    1.63 +  _STLP_DEBUG_CHECK(__check_range(__first, __last))
    1.64 +  for ( ; __first != __last; ++__first)
    1.65 +    _Init = __binary_op(_Init, *__first);
    1.66 +  return _Init;
    1.67 +}
    1.68 +
    1.69 +template <class _InputIterator1, class _InputIterator2, class _Tp>
    1.70 +_STLP_INLINE_LOOP
    1.71 +_Tp inner_product(_InputIterator1 __first1, _InputIterator1 __last1,
    1.72 +                  _InputIterator2 __first2, _Tp _Init)
    1.73 +{
    1.74 +  _STLP_DEBUG_CHECK(__check_range(__first1, __last1))
    1.75 +  for ( ; __first1 != __last1; ++__first1, ++__first2)
    1.76 +    _Init = _Init + (*__first1 * *__first2);
    1.77 +  return _Init;
    1.78 +}
    1.79 +
    1.80 +template <class _InputIterator1, class _InputIterator2, class _Tp,
    1.81 +          class _BinaryOperation1, class _BinaryOperation2>
    1.82 +_STLP_INLINE_LOOP
    1.83 +_Tp inner_product(_InputIterator1 __first1, _InputIterator1 __last1,
    1.84 +                  _InputIterator2 __first2, _Tp _Init, 
    1.85 +                  _BinaryOperation1 __binary_op1,
    1.86 +                  _BinaryOperation2 __binary_op2)
    1.87 +{
    1.88 +  _STLP_DEBUG_CHECK(__check_range(__first1, __last1))
    1.89 +  for ( ; __first1 != __last1; ++__first1, ++__first2)
    1.90 +    _Init = __binary_op1(_Init, __binary_op2(*__first1, *__first2));
    1.91 +  return _Init;
    1.92 +}
    1.93 +
    1.94 +template <class _InputIterator, class _OutputIterator, class _Tp,
    1.95 +          class _BinaryOperation>
    1.96 +_OutputIterator 
    1.97 +__partial_sum(_InputIterator __first, _InputIterator __last, 
    1.98 +              _OutputIterator __result, _Tp*, _BinaryOperation __binary_op);
    1.99 +
   1.100 +
   1.101 +template <class _InputIterator, class _OutputIterator>
   1.102 +inline _OutputIterator 
   1.103 +partial_sum(_InputIterator __first, _InputIterator __last,
   1.104 +            _OutputIterator __result) {
   1.105 +  return __partial_sum(__first, __last, __result, _STLP_VALUE_TYPE(__first, _InputIterator),
   1.106 +                       __plus(_STLP_VALUE_TYPE(__first, _InputIterator)));
   1.107 +}
   1.108 +
   1.109 +template <class _InputIterator, class _OutputIterator, class _BinaryOperation>
   1.110 +inline _OutputIterator 
   1.111 +partial_sum(_InputIterator __first, _InputIterator __last,
   1.112 +            _OutputIterator __result, _BinaryOperation __binary_op) {
   1.113 +  return __partial_sum(__first, __last, __result, _STLP_VALUE_TYPE(__first, _InputIterator), 
   1.114 +                       __binary_op);
   1.115 +}
   1.116 +
   1.117 +
   1.118 +template <class _InputIterator, class _OutputIterator, class _Tp, 
   1.119 +          class _BinaryOperation>
   1.120 +_OutputIterator
   1.121 +__adjacent_difference(_InputIterator __first, _InputIterator __last, 
   1.122 +                      _OutputIterator __result, _Tp*,
   1.123 +                      _BinaryOperation __binary_op);
   1.124 +
   1.125 +template <class _InputIterator, class _OutputIterator>
   1.126 +inline _OutputIterator
   1.127 +adjacent_difference(_InputIterator __first,
   1.128 +                    _InputIterator __last, _OutputIterator __result) {
   1.129 +  return __adjacent_difference(__first, __last, __result,
   1.130 +                               _STLP_VALUE_TYPE(__first, _InputIterator),
   1.131 +                               __minus(_STLP_VALUE_TYPE(__first, _InputIterator)));
   1.132 +}
   1.133 +
   1.134 +template <class _InputIterator, class _OutputIterator, class _BinaryOperation>
   1.135 +_OutputIterator 
   1.136 +adjacent_difference(_InputIterator __first, _InputIterator __last,
   1.137 +                    _OutputIterator __result, _BinaryOperation __binary_op) {
   1.138 +  return __adjacent_difference(__first, __last, __result,
   1.139 +                               _STLP_VALUE_TYPE(__first, _InputIterator),
   1.140 +                               __binary_op);
   1.141 +}
   1.142 +
   1.143 +template <class _Tp, class _Integer, class _MonoidOperation>
   1.144 +_Tp __power(_Tp __x, _Integer __n, _MonoidOperation __opr);
   1.145 +
   1.146 +# ifndef _STLP_NO_EXTENSIONS
   1.147 +
   1.148 +// Returns __x ** __n, where __n >= 0.  _Note that "multiplication"
   1.149 +// is required to be associative, but not necessarily commutative.
   1.150 +
   1.151 +template <class _Tp, class _Integer>
   1.152 +inline _Tp __power(_Tp __x, _Integer __n)
   1.153 +{
   1.154 +  return __power(__x, __n, multiplies<_Tp>());
   1.155 +}
   1.156 +
   1.157 +// Alias for the internal name __power.  Note that power is an extension,
   1.158 +// not part of the C++ standard.
   1.159 +template <class _Tp, class _Integer, class _MonoidOperation>
   1.160 +inline _Tp power(_Tp __x, _Integer __n, _MonoidOperation __opr) {
   1.161 +  return __power(__x, __n, __opr);
   1.162 +}
   1.163 +
   1.164 +
   1.165 +template <class _Tp, class _Integer>
   1.166 +inline _Tp power(_Tp __x, _Integer __n) {
   1.167 +  return __power(__x, __n, multiplies<_Tp>());
   1.168 +}
   1.169 +
   1.170 +// iota is not part of the C++ standard.  It is an extension.
   1.171 +
   1.172 +template <class _ForwardIterator, class _Tp>
   1.173 +_STLP_INLINE_LOOP
   1.174 +void 
   1.175 +iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __val)
   1.176 +{
   1.177 +  _STLP_DEBUG_CHECK(__check_range(__first, __last))
   1.178 +  while (__first != __last)
   1.179 +    *__first++ = __val++;
   1.180 +}
   1.181 +# endif
   1.182 +
   1.183 +_STLP_END_NAMESPACE
   1.184 +
   1.185 +# if !defined (_STLP_LINK_TIME_INSTANTIATION)
   1.186 +#  include <stl/_numeric.c>
   1.187 +# endif
   1.188 +
   1.189 +#endif /* _STLP_INTERNAL_NUMERIC_H */
   1.190 +
   1.191 +// Local Variables:
   1.192 +// mode:C++
   1.193 +// End: