30 #include <boost/iterator/transform_iterator.hpp> 31 #include <boost/iterator/filter_iterator.hpp> 33 #pragma GCC diagnostic push 34 #pragma GCC diagnostic ignored "-Wunused-variable" 35 #pragma GCC diagnostic ignored "-Wunused-local-typedefs" 37 #include <boost/bind.hpp> 39 #pragma GCC diagnostic pop 41 #include <boost/ptr_container/serialize_ptr_map.hpp> 42 #include <boost/shared_ptr.hpp> 51 class ValueAutomaticCasting;
79 typedef boost::ptr_map<
84 boost::fast_pool_allocator<std::pair<const Key, void*> > >
KeyValueMap;
119 typedef boost::transform_iterator<
120 boost::function1<KeyValuePair, const KeyValuePtrPair&>, KeyValueMap::iterator>
iterator;
123 typedef boost::transform_iterator<
124 boost::function1<ConstKeyValuePair, const ConstKeyValuePtrPair&>, KeyValueMap::const_iterator>
const_iterator;
127 typedef boost::transform_iterator<
128 boost::function1<KeyValuePair, const KeyValuePtrPair&>, KeyValueMap::reverse_iterator>
reverse_iterator;
131 typedef boost::transform_iterator<
132 boost::function1<ConstKeyValuePair, const ConstKeyValuePtrPair&>, KeyValueMap::const_reverse_iterator>
const_reverse_iterator;
137 template<
class ValueType = Value>
141 template<
class ValueType = Value>
158 Values(std::initializer_list<ConstKeyValuePair>
init);
164 template<
class ValueType>
168 template<
class ValueType>
190 template <
typename ValueType>
191 const ValueType at(Key
j)
const;
201 const Value& at(Key j)
const;
206 bool exists(Key j)
const;
212 template<
typename ValueType>
213 boost::optional<const ValueType&> exists(Key j)
const;
217 iterator
find(Key j) {
return boost::make_transform_iterator(values_.find(j), &make_deref_pair); }
221 const_iterator
find(Key j)
const {
return boost::make_transform_iterator(values_.find(j), &make_const_deref_pair); }
224 iterator
lower_bound(Key j) {
return boost::make_transform_iterator(values_.lower_bound(j), &make_deref_pair); }
227 const_iterator
lower_bound(Key j)
const {
return boost::make_transform_iterator(values_.lower_bound(j), &make_const_deref_pair); }
230 iterator
upper_bound(Key j) {
return boost::make_transform_iterator(values_.upper_bound(j), &make_deref_pair); }
233 const_iterator
upper_bound(Key j)
const {
return boost::make_transform_iterator(values_.upper_bound(j), &make_const_deref_pair); }
236 size_t size()
const {
return values_.size(); }
239 bool empty()
const {
return values_.empty(); }
241 const_iterator
begin()
const {
return boost::make_transform_iterator(values_.begin(), &make_const_deref_pair); }
242 const_iterator
end()
const {
return boost::make_transform_iterator(values_.end(), &make_const_deref_pair); }
243 iterator
begin() {
return boost::make_transform_iterator(values_.begin(), &make_deref_pair); }
244 iterator
end() {
return boost::make_transform_iterator(values_.end(), &make_deref_pair); }
245 const_reverse_iterator
rbegin()
const {
return boost::make_transform_iterator(values_.rbegin(), &make_const_deref_pair); }
246 const_reverse_iterator
rend()
const {
return boost::make_transform_iterator(values_.rend(), &make_const_deref_pair); }
247 reverse_iterator
rbegin() {
return boost::make_transform_iterator(values_.rbegin(), &make_deref_pair); }
248 reverse_iterator
rend() {
return boost::make_transform_iterator(values_.rend(), &make_deref_pair); }
262 void insert(Key j,
const Value& val);
270 template <
typename ValueType>
271 void insert(Key j,
const ValueType& val);
280 std::pair<iterator, bool> tryInsert(Key j,
const Value&
value);
283 void update(Key j,
const Value& val);
289 template <
typename T>
290 void update(Key j,
const T& val);
333 filter(
const boost::function<
bool(Key)>& filterFcn);
354 template<
class ValueType>
356 filter(
const boost::function<
bool(Key)>& filterFcn = &_truePredicate<Key>);
372 filter(
const boost::function<
bool(Key)>& filterFcn)
const;
392 template<
class ValueType>
394 filter(
const boost::function<
bool(Key)>& filterFcn = &_truePredicate<Key>)
const;
397 template<
class ValueType>
400 for (
const auto key_value : *
this) {
410 template<
class ValueType>
418 friend class boost::serialization::access;
419 template<
class ARCHIVE>
421 ar & BOOST_SERIALIZATION_NVP(values_);
428 return KeyValuePair(key_value.first, *key_value.second); }
448 Key
key() const noexcept {
return key_; }
451 GTSAM_EXPORT
const char* what()
const noexcept
override;
466 operation_(operation), key_(
key) {}
471 Key
key() const noexcept {
return key_; }
474 GTSAM_EXPORT
const char* what()
const noexcept
override;
490 const std::type_info& storedTypeId,
const std::type_info& requestedTypeId) noexcept :
491 key_(
key), storedTypeId_(storedTypeId), requestedTypeId_(requestedTypeId) {}
496 Key
key() const noexcept {
return key_; }
505 GTSAM_EXPORT
const char* what()
const noexcept
override;
516 const char*
what() const noexcept
override {
517 return "The Values 'this' and the argument passed to Values::localCoordinates have mismatched keys and values";
533 M1_(
M1), N1_(N1), M2_(
M2), N2_(N2) {
539 GTSAM_EXPORT
const char* what()
const noexcept
override;
void print(const Matrix &A, const string &s, ostream &stream)
static bool filterHelper(const boost::function< bool(Key)> filter, const ConstKeyValuePair &key_value)
boost::ptr_map< Key, Value, std::less< Key >, ValueCloneAllocator, boost::fast_pool_allocator< std::pair< const Key, void * > > > KeyValueMap
const_reverse_iterator rend() const
iterator lower_bound(Key j)
static bool _truePredicate(const T &)
static void deallocate_clone(const Value *a)
~DynamicValuesMismatched() noexceptoverride
KeyValueMap::iterator::value_type KeyValuePtrPair
reverse_iterator rbegin()
A key-value pair, which you get by dereferencing iterators.
Key key() const noexcept
The key that was attempted to be accessed that does not exist.
virtual Value * clone_() const =0
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 y set format x g set format y g set format x2 g set format y2 g set format z g set angles radians set nogrid set key title set key left top Right noreverse box linetype linewidth samplen spacing width set nolabel set noarrow set nologscale set logscale x set set pointsize set encoding default set nopolar set noparametric set view
Key key() const noexcept
The duplicate key that was attempted to be added.
const_iterator find(Key j) const
const char * what() const noexceptoverride
virtual void deallocate_() const =0
ValuesKeyDoesNotExist(const char *operation, Key key) noexcept
Construct with the key that does not exist in the values.
A key-value pair, which you get by dereferencing iterators.
boost::transform_iterator< boost::function1< ConstKeyValuePair, const ConstKeyValuePtrPair & >, KeyValueMap::const_reverse_iterator > const_reverse_iterator
Const reverse iterator, with value type ConstKeyValuePair.
static const KeyFormatter DefaultKeyFormatter
KeyValueMap::const_iterator::value_type ConstKeyValuePtrPair
const Value & value
The value.
const char * operation_
The operation that attempted to access the key.
boost::transform_iterator< boost::function1< KeyValuePair, const KeyValuePtrPair & >, KeyValueMap::iterator > iterator
Mutable forward iterator, with value type KeyValuePair.
static ConstKeyValuePair make_const_deref_pair(const KeyValueMap::const_iterator::value_type &key_value)
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
~NoMatchFoundForFixed() noexceptoverride
M1<< 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12;Map< MatrixXf > M2(M1.data(), 6, 2)
boost::shared_ptr< Values > shared_ptr
A shared_ptr to this class.
const_iterator end() const
const_iterator upper_bound(Key j) const
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Array< double, 1, 3 > e(1./3., 0.5, 2.)
boost::transform_iterator< boost::function1< ConstKeyValuePair, const ConstKeyValuePtrPair & >, KeyValueMap::const_iterator > const_iterator
Const forward iterator, with value type ConstKeyValuePair.
const_iterator begin() const
ValuesKeyAlreadyExists(Key key) noexcept
Construct with the key-value pair attempted to be added.
const mpreal dim(const mpreal &a, const mpreal &b, mp_rnd_t r=mpreal::get_default_rnd())
KeyValuePair(Key _key, Value &_value)
A small structure to hold a non zero as a triplet (i,j,value).
const Key key_
The key that already existed.
std::vector< float > Values
NoMatchFoundForFixed(size_t M1, size_t N1, size_t M2, size_t N2) noexcept
const std::type_info & requestedTypeId_
double atDouble(size_t key) const
version for double
const Key key_
The key requested.
~ValuesKeyDoesNotExist() noexceptoverride
const std::type_info & storedTypeId_
~ValuesIncorrectType() noexceptoverride
static Value * allocate_clone(const Value &a)
boost::shared_ptr< const Values > const_shared_ptr
A const shared_ptr to this class.
const std::type_info & requestedTypeId() const
The requested typeid.
ValuesIncorrectType(Key key, const std::type_info &storedTypeId, const std::type_info &requestedTypeId) noexcept
Construct with the key that does not exist in the values.
DynamicValuesMismatched() noexcept
static KeyValuePair make_deref_pair(const KeyValueMap::iterator::value_type &key_value)
~ValuesKeyAlreadyExists() noexceptoverride
void insertDouble(Key j, double c)
version for double
const_iterator lower_bound(Key j) const
boost::transform_iterator< boost::function1< KeyValuePair, const KeyValuePtrPair & >, KeyValueMap::reverse_iterator > reverse_iterator
Mutable reverse iterator, with value type KeyValuePair.
const std::type_info & storedTypeId() const
The typeid of the value stores in the Values.
void serialize(ARCHIVE &ar, const unsigned int)
std::uint64_t Key
Integer nonlinear key type.
ConstKeyValuePair(const KeyValuePair &kv)
const_reverse_iterator rbegin() const
iterator upper_bound(Key j)
Key key() const noexcept
The key that was attempted to be accessed that does not exist.
const Key key_
The key that does not exist.
ConstKeyValuePair(Key _key, const Value &_value)