FastMap.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 #ifdef GTSAM_ENABLE_BOOST_SERIALIZATION
23 #include <boost/serialization/nvp.hpp>
24 #include <boost/serialization/map.hpp>
25 #endif
26 #include <map>
27 
28 namespace gtsam {
29 
38 template<typename KEY, typename VALUE>
39 class FastMap : public std::map<KEY, VALUE, std::less<KEY>,
40  typename internal::FastDefaultAllocator<std::pair<const KEY, VALUE> >::type> {
41 
42 public:
43 
44  typedef std::map<KEY, VALUE, std::less<KEY>,
46 
48  FastMap() {}
49 
51  template<typename INPUTITERATOR>
52  explicit FastMap(INPUTITERATOR first, INPUTITERATOR last) : Base(first, last) {}
53 
56 
58  FastMap(const Base& x) : Base(x) {}
59 
61  operator std::map<KEY,VALUE>() const {
62  return std::map<KEY,VALUE>(this->begin(), this->end());
63  }
64 
66  bool insert2(const KEY& key, const VALUE& val) { return Base::insert({key, val}).second; }
67 
69  bool exists(const KEY& e) const { return this->find(e) != this->end(); }
70 
71 private:
72 #ifdef GTSAM_ENABLE_BOOST_SERIALIZATION
73 
74  friend class boost::serialization::access;
75  template<class ARCHIVE>
76  void serialize(ARCHIVE & ar, const unsigned int /*version*/) {
77  ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base);
78  }
79 #endif
80 };
81 
82 }
gtsam::FastMap::insert2
bool insert2(const KEY &key, const VALUE &val)
Definition: FastMap.h:66
e
Array< double, 1, 3 > e(1./3., 0.5, 2.)
x
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
Definition: gnuplot_common_settings.hh:12
gtsam::FastMap
Definition: FastMap.h:39
gtsam::FastMap::FastMap
FastMap()
Definition: FastMap.h:48
type
Definition: pytypes.h:1525
Eigen::last
static const symbolic::SymbolExpr< internal::symbolic_last_tag > last
Definition: IndexedViewHelper.h:38
gtsam::FastMap::FastMap
FastMap(const FastMap< KEY, VALUE > &x)
Definition: FastMap.h:55
gtsam::internal::FastDefaultAllocator
Default allocator for list, map, and set types.
Definition: FastDefaultAllocator.h:49
Eigen::internal::VALUE
@ VALUE
Definition: SpecialFunctionsImpl.h:729
gtsam::FastMap::exists
bool exists(const KEY &e) const
Definition: FastMap.h:69
gtsam::FastMap::FastMap
FastMap(INPUTITERATOR first, INPUTITERATOR last)
Definition: FastMap.h:52
test_KarcherMeanFactor.KEY
int KEY
Definition: test_KarcherMeanFactor.py:22
key
const gtsam::Symbol key('X', 0)
gtsam
traits
Definition: SFMdata.h:40
gtsam::FastMap::FastMap
FastMap(const Base &x)
Definition: FastMap.h:58
gtsam::FastMap::Base
std::map< KEY, VALUE, std::less< KEY >, typename internal::FastDefaultAllocator< std::pair< const KEY, VALUE > >::type > Base
Definition: FastMap.h:45
FastDefaultAllocator.h
An easy way to control which allocator is used for Fast* collections.
Eigen::placeholders::end
static const EIGEN_DEPRECATED end_t end
Definition: IndexedViewHelper.h:181
Base
Definition: test_virtual_functions.cpp:156
insert
A insert(1, 2)=0


gtsam
Author(s):
autogenerated on Thu Dec 19 2024 04:01:07