]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/accumulators/include/boost/accumulators/statistics/tail_variate.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / accumulators / include / boost / accumulators / statistics / tail_variate.hpp
CommitLineData
7c673cae
FG
1///////////////////////////////////////////////////////////////////////////////
2// tail_variate.hpp
3//
4// Copyright 2005 Eric Niebler, Michael Gauckler. Distributed under the Boost
5// Software License, Version 1.0. (See accompanying file
6// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7
8#ifndef BOOST_STAT_STATISTICS_TAIL_VARIATE_HPP_EAN_28_10_2005
9#define BOOST_STAT_STATISTICS_TAIL_VARIATE_HPP_EAN_28_10_2005
10
11#include <boost/range.hpp>
12#include <boost/mpl/always.hpp>
13#include <boost/mpl/placeholders.hpp>
14#include <boost/iterator/reverse_iterator.hpp>
15#include <boost/iterator/permutation_iterator.hpp>
16#include <boost/accumulators/framework/accumulator_base.hpp>
17#include <boost/accumulators/framework/extractor.hpp>
18#include <boost/accumulators/framework/depends_on.hpp>
19#include <boost/accumulators/statistics_fwd.hpp>
20#include <boost/accumulators/statistics/tail.hpp>
21
22namespace boost { namespace accumulators
23{
24
25namespace impl
26{
27 ///////////////////////////////////////////////////////////////////////////////
28 // tail_variate_impl
29 template<typename VariateType, typename VariateTag, typename LeftRight>
30 struct tail_variate_impl
31 : accumulator_base
32 {
33 // for boost::result_of
34 typedef
35 typename detail::tail_range<
36 typename std::vector<VariateType>::const_iterator
37 , std::vector<std::size_t>::iterator
38 >::type
39 result_type;
40
41 template<typename Args>
42 tail_variate_impl(Args const &args)
43 : variates(args[tag::tail<LeftRight>::cache_size], args[parameter::keyword<VariateTag>::get() | VariateType()])
44 {
45 }
46
47 template<typename Args>
48 void assign(Args const &args, std::size_t index)
49 {
50 this->variates[index] = args[parameter::keyword<VariateTag>::get()];
51 }
52
53 template<typename Args>
54 result_type result(Args const &args) const
55 {
56 // getting the order result causes the indices vector to be sorted.
57 extractor<tag::tail<LeftRight> > const some_tail = {};
58 return this->do_result(some_tail(args));
59 }
60
61 private:
62 template<typename TailRng>
63 result_type do_result(TailRng const &rng) const
64 {
65 return detail::make_tail_range(
66 this->variates.begin()
67 , rng.end().base().base() // the index iterator
68 , rng.begin().base().base() // (begin and end reversed because these are reverse iterators)
69 );
70 }
71
72 std::vector<VariateType> variates;
73 };
74
75} // namespace impl
76
77///////////////////////////////////////////////////////////////////////////////
78// tag::tail_variate<>
79//
80namespace tag
81{
82 template<typename VariateType, typename VariateTag, typename LeftRight>
83 struct tail_variate
84 : depends_on<tail<LeftRight> >
85 {
86 /// INTERNAL ONLY
87 ///
88 typedef mpl::always<accumulators::impl::tail_variate_impl<VariateType, VariateTag, LeftRight> > impl;
89 };
90
91 struct abstract_tail_variate
92 : depends_on<>
93 {
94 };
95
96 template<typename LeftRight>
97 struct tail_weights
98 : depends_on<tail<LeftRight> >
99 {
100 /// INTERNAL ONLY
101 ///
102 typedef accumulators::impl::tail_variate_impl<mpl::_2, tag::weight, LeftRight> impl;
103 };
104
105 struct abstract_tail_weights
106 : depends_on<>
107 {
108 };
109}
110
111///////////////////////////////////////////////////////////////////////////////
112// extract::tail_variate
113// extract::tail_weights
114//
115namespace extract
116{
117 extractor<tag::abstract_tail_variate> const tail_variate = {};
118 extractor<tag::abstract_tail_weights> const tail_weights = {};
119
120 BOOST_ACCUMULATORS_IGNORE_GLOBAL(tail_variate)
121 BOOST_ACCUMULATORS_IGNORE_GLOBAL(tail_weights)
122}
123
124using extract::tail_variate;
125using extract::tail_weights;
126
127template<typename VariateType, typename VariateTag, typename LeftRight>
128struct feature_of<tag::tail_variate<VariateType, VariateTag, LeftRight> >
129 : feature_of<tag::abstract_tail_variate>
130{
131};
132
133template<typename LeftRight>
134struct feature_of<tag::tail_weights<LeftRight> >
135{
136 typedef tag::abstract_tail_weights type;
137};
138
139}} // namespace boost::accumulators
140
141#endif