gtsam  4.0.0
gtsam
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/list.hpp>
26 
27 namespace gtsam {
28 
37 template<typename VALUE>
38 class FastList: public std::list<VALUE, typename internal::FastDefaultAllocator<VALUE>::type> {
39 
40 public:
41 
42  typedef std::list<VALUE, typename internal::FastDefaultAllocator<VALUE>::type> Base;
43 
45  FastList() {}
46 
48  template<typename INPUTITERATOR>
49  explicit FastList(INPUTITERATOR first, INPUTITERATOR last) : Base(first, last) {}
50 
52  FastList(const FastList<VALUE>& x) : Base(x) {}
53 
55  FastList(const Base& x) : Base(x) {}
56 
57 #ifdef GTSAM_ALLOCATOR_BOOSTPOOL
58 
59  FastList(const std::list<VALUE>& x) {
60  // This if statement works around a bug in boost pool allocator and/or
61  // STL vector where if the size is zero, the pool allocator will allocate
62  // huge amounts of memory.
63  if(x.size() > 0)
64  Base::assign(x.begin(), x.end());
65  }
66 #endif
67 
69  operator std::list<VALUE>() const {
70  return std::list<VALUE>(this->begin(), this->end());
71  }
72 
73 private:
75  friend class boost::serialization::access;
76  template<class ARCHIVE>
77  void serialize(ARCHIVE & ar, const unsigned int /*version*/) {
78  ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base);
79  }
80 
81 };
82 
83 }
FastList(const FastList< VALUE > &x)
Copy constructor from another FastList.
Definition: FastList.h:52
Definition: FastList.h:38
An easy way to control which allocator is used for Fast* collections.
FastList(const Base &x)
Copy constructor from the base list class.
Definition: FastList.h:55
FastList(INPUTITERATOR first, INPUTITERATOR last)
Constructor from a range, passes through to base class.
Definition: FastList.h:49
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
FastList()
Default constructor.
Definition: FastList.h:45