Loading...
Searching...
No Matches
FastList.h
Go to the documentation of this file.
/* ----------------------------------------------------------------------------
* GTSAM Copyright 2010, Georgia Tech Research Corporation,
* Atlanta, Georgia 30332-0415
* All Rights Reserved
* Authors: Frank Dellaert, et al. (see THANKS for the full author list)
* See LICENSE for the license information
* -------------------------------------------------------------------------- */
#pragma once
#include <gtsam/base/FastDefaultAllocator.h>
#include <list>
#include <boost/utility/enable_if.hpp>
#include <boost/serialization/nvp.hpp>
#include <boost/serialization/version.hpp>
#include <boost/serialization/optional.hpp>
#include <boost/serialization/list.hpp>
namespace gtsam {
template<typename VALUE>
class FastList: public std::list<VALUE, typename internal::FastDefaultAllocator<VALUE>::type> {
public:
typedef std::list<VALUE, typename internal::FastDefaultAllocator<VALUE>::type> Base;
FastList() {}
template<typename INPUTITERATOR>
explicit FastList(INPUTITERATOR first, INPUTITERATOR last) : Base(first, last) {}
FastList(const FastList<VALUE>& x) : Base(x) {}
FastList(const Base& x) : Base(x) {}
FastList(std::initializer_list<VALUE> l) : Base(l) {}
#ifdef GTSAM_ALLOCATOR_BOOSTPOOL
FastList(const std::list<VALUE>& x) {
// This if statement works around a bug in boost pool allocator and/or
// STL vector where if the size is zero, the pool allocator will allocate
// huge amounts of memory.
if(x.size() > 0)
Base::assign(x.begin(), x.end());
}
#endif
operator std::list<VALUE>() const {
return std::list<VALUE>(this->begin(), this->end());
}
private:
friend class boost::serialization::access;
template<class ARCHIVE>
void serialize(ARCHIVE & ar, const unsigned int /*version*/) {
ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base);
}
};
}
FastDefaultAllocator.h
An easy way to control which allocator is used for Fast* collections.
gtsam
Global functions in a separate testing namespace.
Definition chartTesting.h:28
gtsam::FastList::FastList
FastList(INPUTITERATOR first, INPUTITERATOR last)
Constructor from a range, passes through to base class.
Definition FastList.h:51
gtsam::FastList::FastList
FastList()
Default constructor.
Definition FastList.h:47
gtsam::FastList::FastList
FastList(std::initializer_list< VALUE > l)
Construct from c++11 initializer list:
Definition FastList.h:60
gtsam::FastList::FastList
FastList(const FastList< VALUE > &x)
Copy constructor from another FastList.
Definition FastList.h:54
gtsam::FastList::FastList
FastList(const Base &x)
Copy constructor from the base list class.
Definition FastList.h:57