正文

泛型数值STL算法2008-12-15 15:07:00

【评论】 【打印】 【字体: 】 本文链接:http://blog.pfan.cn/rickone/39919.html

分享到:

iota(first, last, value)
返回void,对于0 <= n < (last - first),*(first + n) = value + n

accumulate(first, last, init)
返回s,s = init + *first + *(first + 1) + ... + *(last -1)
accumulate(first, last, init, pred)
返回s,s = pred(pred(...pred(pred(init, *first), *(first + 1)),...), *(last - 1))

inner_product(first1, last1, first2, init)
返回s,s = init + *first1 * *first2 + *(first1 + 1) * *(first2 + 1) + ... + *(last1 - 1) * *(first2 + (last1 - first1) - 1)
inner_product(first1, last1, first2, init, pred1, pred2)
返回s,s = init pred1 *first1 pred2 *first2 ...

partial_sum(first, last, result)
返回result+(last-first),对于0 <= n < (last-first),*(result + n) = accumulate(first, first + n, 0)
partial_sum(first, last, result, pred)
返回result+(last-first),对于0 <= n < (last-first),*(result + n) = accumulate(first, first + n, 0, pred)

adjacent_difference(first, last, result)
返回result+(last-first),*result = *first,对于1 <= n < (last-first),*(result + n) = *(first + n) - *(first + n - 1)

adjacent_difference(first, last, result, pred)
返回result+(last-first),*result = *first,对于1 <= n < (last-first),*(result + n) = pred(*(first + n), *(first + n - 1))

power(x, n)
返回p,p = x * x * ... * x
power(x, n, pred)
返回p,p = x pred x pred ...

阅读(5779) | 评论(4)


版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!

评论

loading...
您需要登录后才能评论,请 登录 或者 注册