FastList.h
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2 
3  * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4  * Atlanta, Georgia 30332-0415
5  * All Rights Reserved
6  * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7 
8  * See LICENSE for the license information
9 
10  * -------------------------------------------------------------------------- */
11 
19 #pragma once
20 
22 #include <list>
23 #include <boost/utility/enable_if.hpp>
24 #include <boost/serialization/nvp.hpp>
25 #include <boost/serialization/version.hpp>
26 #include <boost/serialization/optional.hpp>
27 #include <boost/serialization/list.hpp>
28 
29 namespace gtsam {
30 
39 template<typename VALUE>
40 class FastList: public std::list<VALUE, typename internal::FastDefaultAllocator<VALUE>::type> {
41 
42 public:
43 
45 
47  FastList() {}
48 
50  template<typename INPUTITERATOR>
51  explicit FastList(INPUTITERATOR first, INPUTITERATOR last) : Base(first, last) {}
52 
54  FastList(const FastList<VALUE>& x) : Base(x) {}
55 
57  FastList(const Base& x) : Base(x) {}
58 
59 #ifdef GTSAM_ALLOCATOR_BOOSTPOOL
60 
61  FastList(const std::list<VALUE>& x) {
62  // This if statement works around a bug in boost pool allocator and/or
63  // STL vector where if the size is zero, the pool allocator will allocate
64  // huge amounts of memory.
65  if(x.size() > 0)
66  Base::assign(x.begin(), x.end());
67  }
68 #endif
69 
71  operator std::list<VALUE>() const {
72  return std::list<VALUE>(this->begin(), this->end());
73  }
74 
75 private:
77  friend class boost::serialization::access;
78  template<class ARCHIVE>
79  void serialize(ARCHIVE & ar, const unsigned int /*version*/) {
80  ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base);
81  }
82 
83 };
84 
85 }
constexpr int last(int, int result)
void serialize(ARCHIVE &ar, const unsigned int)
Definition: FastList.h:79
constexpr int first(int i)
Implementation details for constexpr functions.
FastList(const Base &x)
Definition: FastList.h:57
std::list< VALUE, typename internal::FastDefaultAllocator< VALUE >::type > Base
Definition: FastList.h:44
FastList(INPUTITERATOR first, INPUTITERATOR last)
Definition: FastList.h:51
traits
Definition: chartTesting.h:28
FastList(const FastList< VALUE > &x)
Definition: FastList.h:54
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
An easy way to control which allocator is used for Fast* collections.


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:42:03