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 #include <boost/serialization/nvp.hpp>
23 #include <boost/serialization/map.hpp>
24 #include <map>
25 
26 namespace gtsam {
27 
36 template<typename KEY, typename VALUE>
37 class FastMap : public std::map<KEY, VALUE, std::less<KEY>,
38  typename internal::FastDefaultAllocator<std::pair<const KEY, VALUE> >::type> {
39 
40 public:
41 
42  typedef std::map<KEY, VALUE, std::less<KEY>,
44 
46  FastMap() {}
47 
49  template<typename INPUTITERATOR>
50  explicit FastMap(INPUTITERATOR first, INPUTITERATOR last) : Base(first, last) {}
51 
53  FastMap(const FastMap<KEY,VALUE>& x) : Base(x) {}
54 
56  FastMap(const Base& x) : Base(x) {}
57 
59  operator std::map<KEY,VALUE>() const {
60  return std::map<KEY,VALUE>(this->begin(), this->end());
61  }
62 
64  bool insert2(const KEY& key, const VALUE& val) { return Base::insert(std::make_pair(key, val)).second; }
65 
67  bool exists(const KEY& e) const { return this->find(e) != this->end(); }
68 
69 private:
71  friend class boost::serialization::access;
72  template<class ARCHIVE>
73  void serialize(ARCHIVE & ar, const unsigned int /*version*/) {
74  ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Base);
75  }
76 };
77 
78 }
constexpr int last(int, int result)
bool exists(const KEY &e) const
Definition: FastMap.h:67
A insert(1, 2)=0
FastMap(INPUTITERATOR first, INPUTITERATOR last)
Definition: FastMap.h:50
Default allocator for list, map, and set types.
std::map< KEY, VALUE, std::less< KEY >, typename internal::FastDefaultAllocator< std::pair< const KEY, VALUE > >::type > Base
Definition: FastMap.h:43
constexpr int first(int i)
Implementation details for constexpr functions.
Array< double, 1, 3 > e(1./3., 0.5, 2.)
FastMap(const Base &x)
Definition: FastMap.h:56
void serialize(ARCHIVE &ar, const unsigned int)
Definition: FastMap.h:73
FastMap(const FastMap< KEY, VALUE > &x)
Definition: FastMap.h:53
traits
Definition: chartTesting.h:28
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.
bool insert2(const KEY &key, const VALUE &val)
Definition: FastMap.h:64
Definition: pytypes.h:897


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