27 # include <tbb/concurrent_unordered_map.h> 28 # undef min // TBB seems to include Windows.h which defines these macros that cause problems 33 # define CONCURRENT_MAP_BASE tbb::concurrent_unordered_map<KEY, VALUE> 39 # define CONCURRENT_MAP_BASE gtsam::FastMap<KEY, VALUE> 43 #include <boost/serialization/nvp.hpp> 44 #include <boost/serialization/split_member.hpp> 45 #include <boost/static_assert.hpp> 59 template<
typename KEY,
typename VALUE>
64 typedef CONCURRENT_MAP_BASE Base;
70 template<
typename INPUTITERATOR>
71 ConcurrentMap(INPUTITERATOR first, INPUTITERATOR last) : Base(first, last) {}
80 bool exists(
const KEY& e)
const {
return this->count(e); }
85 void unsafe_erase(
typename Base::iterator position) { ((Base*)
this)->erase(position); }
86 typename Base::size_type unsafe_erase(
const KEY& k) {
return ((Base*)
this)->erase(k); }
87 void unsafe_erase(
typename Base::iterator first,
typename Base::iterator last) {
88 return ((Base*)
this)->erase(first, last); }
96 friend class boost::serialization::access;
97 template<
class Archive>
98 void save(Archive& ar,
const unsigned int )
const 101 FastVector<std::pair<KEY, VALUE> > map(this->size());
102 std::copy(this->begin(), this->end(), map.begin());
103 ar & BOOST_SERIALIZATION_NVP(map);
105 template<
class Archive>
106 void load(Archive& ar,
const unsigned int )
109 FastVector<std::pair<KEY, VALUE> > map;
110 ar & BOOST_SERIALIZATION_NVP(map);
111 this->insert(map.begin(), map.end());
113 BOOST_SERIALIZATION_SPLIT_MEMBER()
A thin wrapper around std::vector that uses a custom allocator.
Definition: ConcurrentMap.h:60
Included from all GTSAM files.
void save(const Matrix &A, const string &s, const string &filename)
save a matrix to file, which can be loaded by matlab
Definition: Matrix.cpp:162
A thin wrapper around std::map that uses boost's fast_pool_allocator.
ConcurrentMap(const ConcurrentMap< KEY, VALUE > &x)
Copy constructor from another ConcurrentMap.
Definition: ConcurrentMap.h:74
ConcurrentMap(INPUTITERATOR first, INPUTITERATOR last)
Constructor from a range, passes through to base class.
Definition: ConcurrentMap.h:71
bool exists(const KEY &e) const
Handy 'exists' function.
Definition: ConcurrentMap.h:80
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
ConcurrentMap()
Default constructor.
Definition: ConcurrentMap.h:67
ConcurrentMap(const Base &x)
Copy constructor from the base map class.
Definition: ConcurrentMap.h:77