Loading...
Searching...
No Matches
FastMap.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 <boost/serialization/nvp.hpp>
#include <boost/serialization/map.hpp>
#include <map>
namespace gtsam {
template<typename KEY, typename VALUE>
class FastMap : public std::map<KEY, VALUE, std::less<KEY>,
typename internal::FastDefaultAllocator<std::pair<const KEY, VALUE> >::type> {
public:
typedef std::map<KEY, VALUE, std::less<KEY>,
typename internal::FastDefaultAllocator<std::pair<const KEY, VALUE> >::type > Base;
FastMap() {}
template<typename INPUTITERATOR>
explicit FastMap(INPUTITERATOR first, INPUTITERATOR last) : Base(first, last) {}
FastMap(const FastMap<KEY,VALUE>& x) : Base(x) {}
FastMap(const Base& x) : Base(x) {}
operator std::map<KEY,VALUE>() const {
return std::map<KEY,VALUE>(this->begin(), this->end());
}
bool insert2(const KEY& key, const VALUE& val) { return Base::insert(std::make_pair(key, val)).second; }
bool exists(const KEY& e) const { return this->find(e) != 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::internal::FastDefaultAllocator
Default allocator for list, map, and set types.
Definition FastDefaultAllocator.h:50
gtsam::FastMap::FastMap
FastMap(const Base &x)
Copy constructor from the base map class.
Definition FastMap.h:56
gtsam::FastMap::FastMap
FastMap(INPUTITERATOR first, INPUTITERATOR last)
Constructor from a range, passes through to base class.
Definition FastMap.h:50
gtsam::FastMap::insert2
bool insert2(const KEY &key, const VALUE &val)
Handy 'insert' function for Matlab wrapper.
Definition FastMap.h:64
gtsam::FastMap::FastMap
FastMap(const FastMap< KEY, VALUE > &x)
Copy constructor from another FastMap.
Definition FastMap.h:53
gtsam::FastMap::FastMap
FastMap()
Default constructor.
Definition FastMap.h:46
gtsam::FastMap::exists
bool exists(const KEY &e) const
Handy 'exists' function.
Definition FastMap.h:67