]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/chrono/stopwatches/include/boost/chrono/stopwatches/collectors/laps_sequence_container.hpp
Add patch for failing prerm scripts
[ceph.git] / ceph / src / boost / libs / chrono / stopwatches / include / boost / chrono / stopwatches / collectors / laps_sequence_container.hpp
1 // boost/chrono/stopwatches/collectors/laps_sequence_container.hpp
2 // Copyright 2011 Vicente J. Botet Escriba
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt or
5 // copy at http://www.boost.org/LICENSE_1_0.txt)
6 // See http://www.boost.org/libs/chrono/stopwatches for documentation.
7
8 #ifndef BOOST_CHRONO_STOPWATCHES_MEMORIES_LAPS_CONTAINER_HPP
9 #define BOOST_CHRONO_STOPWATCHES_MEMORIES_LAPS_CONTAINER_HPP
10
11 #include <list>
12
13 namespace boost
14 {
15 namespace chrono
16 {
17
18 template<
19 typename Duration,
20 typename SequenceContainer = std::list<Duration>
21 >
22 struct laps_sequence_container
23 {
24 typedef Duration duration;
25 typedef typename duration::rep rep;
26 typedef SequenceContainer storage_type;
27 typedef typename SequenceContainer::iterator iterator;
28 typedef typename SequenceContainer::const_iterator const_iterator;
29 storage_type cont_;
30
31 void store(duration const& d)
32 {
33 cont_.push_front(d);
34 }
35
36 void reset()
37 {
38 cont_.clear();
39 }
40
41 storage_type const& container() const { return cont_; }
42
43 duration last() const {
44 if (cont_.empty())
45 return duration::zero();
46 else
47 return *cont_.begin();
48 }
49
50 duration elapsed() const {
51 duration elapsed_ = duration::zero();
52 for (const_iterator it = cont_.begin(); it !=cont_.end(); ++it) elapsed_ += *it;
53 return elapsed_;
54 }
55
56 };
57
58
59 } // namespace chrono
60 } // namespace boost
61
62
63 #endif
64
65