Chris@16
|
1 ///////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
2 // rolling_count.hpp
|
Chris@16
|
3 //
|
Chris@16
|
4 // Copyright 2008 Eric Niebler. Distributed under the Boost
|
Chris@16
|
5 // Software License, Version 1.0. (See accompanying file
|
Chris@16
|
6 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
7
|
Chris@16
|
8 #ifndef BOOST_ACCUMULATORS_STATISTICS_ROLLING_COUNT_HPP_EAN_26_12_2008
|
Chris@16
|
9 #define BOOST_ACCUMULATORS_STATISTICS_ROLLING_COUNT_HPP_EAN_26_12_2008
|
Chris@16
|
10
|
Chris@16
|
11 #include <boost/mpl/placeholders.hpp>
|
Chris@16
|
12 #include <boost/accumulators/framework/accumulator_base.hpp>
|
Chris@16
|
13 #include <boost/accumulators/framework/extractor.hpp>
|
Chris@16
|
14 #include <boost/accumulators/numeric/functional.hpp>
|
Chris@16
|
15 #include <boost/accumulators/framework/parameters/sample.hpp>
|
Chris@16
|
16 #include <boost/accumulators/framework/depends_on.hpp>
|
Chris@16
|
17 #include <boost/accumulators/statistics_fwd.hpp>
|
Chris@16
|
18 #include <boost/accumulators/statistics/rolling_window.hpp>
|
Chris@16
|
19
|
Chris@16
|
20 namespace boost { namespace accumulators
|
Chris@16
|
21 {
|
Chris@16
|
22
|
Chris@16
|
23 namespace impl
|
Chris@16
|
24 {
|
Chris@16
|
25
|
Chris@16
|
26 ///////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
27 // rolling_count_impl
|
Chris@16
|
28 // returns the count of elements in the rolling window
|
Chris@16
|
29 template<typename Sample>
|
Chris@16
|
30 struct rolling_count_impl
|
Chris@16
|
31 : accumulator_base
|
Chris@16
|
32 {
|
Chris@16
|
33 typedef std::size_t result_type;
|
Chris@16
|
34
|
Chris@16
|
35 rolling_count_impl(dont_care)
|
Chris@16
|
36 {}
|
Chris@16
|
37
|
Chris@16
|
38 template<typename Args>
|
Chris@16
|
39 result_type result(Args const &args) const
|
Chris@16
|
40 {
|
Chris@16
|
41 return static_cast<std::size_t>(rolling_window_plus1(args).size()) - is_rolling_window_plus1_full(args);
|
Chris@16
|
42 }
|
Chris@16
|
43 };
|
Chris@16
|
44
|
Chris@16
|
45 } // namespace impl
|
Chris@16
|
46
|
Chris@16
|
47 ///////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
48 // tag::rolling_count
|
Chris@16
|
49 //
|
Chris@16
|
50 namespace tag
|
Chris@16
|
51 {
|
Chris@16
|
52 struct rolling_count
|
Chris@16
|
53 : depends_on< rolling_window_plus1 >
|
Chris@16
|
54 {
|
Chris@16
|
55 /// INTERNAL ONLY
|
Chris@16
|
56 ///
|
Chris@16
|
57 typedef accumulators::impl::rolling_count_impl< mpl::_1 > impl;
|
Chris@16
|
58
|
Chris@16
|
59 #ifdef BOOST_ACCUMULATORS_DOXYGEN_INVOKED
|
Chris@16
|
60 /// tag::rolling_window::window_size named parameter
|
Chris@16
|
61 static boost::parameter::keyword<tag::rolling_window_size> const window_size;
|
Chris@16
|
62 #endif
|
Chris@16
|
63 };
|
Chris@16
|
64 } // namespace tag
|
Chris@16
|
65
|
Chris@16
|
66 ///////////////////////////////////////////////////////////////////////////////
|
Chris@16
|
67 // extract::rolling_count
|
Chris@16
|
68 //
|
Chris@16
|
69 namespace extract
|
Chris@16
|
70 {
|
Chris@16
|
71 extractor<tag::rolling_count> const rolling_count = {};
|
Chris@16
|
72
|
Chris@16
|
73 BOOST_ACCUMULATORS_IGNORE_GLOBAL(rolling_count)
|
Chris@16
|
74 }
|
Chris@16
|
75
|
Chris@16
|
76 using extract::rolling_count;
|
Chris@16
|
77
|
Chris@16
|
78 }} // namespace boost::accumulators
|
Chris@16
|
79
|
Chris@16
|
80 #endif
|