32 #ifdef GTSAM_ENABLE_BOOST_SERIALIZATION 33 #include <boost/serialization/unique_ptr.hpp> 45 class ValueAutomaticCasting;
75 std::map<Key, std::unique_ptr<Value>, std::less<Key>,
76 std::allocator<std::pair<const Key, std::unique_ptr<Value>>>>;
125 Values(std::initializer_list<ConstKeyValuePair>
init);
152 template <
typename ValueType>
153 const ValueType at(
Key j)
const;
168 bool exists(
Key j)
const;
174 template<
typename ValueType>
175 const ValueType * exists(
Key j)
const;
178 size_t size()
const {
return values_.size(); }
181 bool empty()
const {
return values_.empty(); }
193 return std::make_unique<ConstKeyValuePair>(it_->first, *(it_->second));
196 return it_ == other.
it_;
245 template <
typename ValueType>
246 void insert(
Key j,
const ValueType& val);
258 template <
typename T>
265 void insert_or_assign(
Key j,
const Value& val);
271 void insert_or_assign(
const Values& values);
274 template <
typename ValueType>
275 void insert_or_assign(
Key j,
const ValueType& val);
304 std::map<Key,size_t> dims()
const;
310 template <
class ValueType>
311 size_t count()
const;
332 template <
class ValueType>
333 std::map<Key, ValueType>
334 extract(
const std::function<
bool(
Key)>& filterFcn = &_truePredicate<Key>)
const;
339 template<
class ValueType>
347 #ifdef GTSAM_ENABLE_BOOST_SERIALIZATION 349 friend class boost::serialization::access;
350 template<
class ARCHIVE>
351 void serialize(ARCHIVE & ar,
const unsigned int ) {
352 ar & BOOST_SERIALIZATION_NVP(values_);
374 Key key() const noexcept {
return key_; }
377 GTSAM_EXPORT
const char* what()
const noexcept
override;
392 operation_(operation), key_(
key) {}
397 Key key() const noexcept {
return key_; }
400 GTSAM_EXPORT
const char* what()
const noexcept
override;
416 const std::type_info& storedTypeId,
const std::type_info& requestedTypeId) noexcept :
417 key_(
key), storedTypeId_(storedTypeId), requestedTypeId_(requestedTypeId) {}
422 Key key() const noexcept {
return key_; }
431 GTSAM_EXPORT
const char* what()
const noexcept
override;
442 const char*
what() const noexcept
override {
443 return "The Values 'this' and the argument passed to Values::localCoordinates have mismatched keys and values";
459 M1_(
M1), N1_(N1), M2_(
M2), N2_(N2) {
465 GTSAM_EXPORT
const char* what()
const noexcept
override;
void print(const Matrix &A, const string &s, ostream &stream)
const gtsam::Symbol key('X', 0)
static bool _truePredicate(const T &)
deref_iterator(const_iterator_type it)
static void deallocate_clone(const Value *a)
std::string serialize(const T &input)
serializes to a string
deref_iterator lower_bound(Key j) const
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.
~ValuesKeyDoesNotExist() noexcept override
std::shared_ptr< const Values > const_shared_ptr
A const shared_ptr to this class.
virtual Value * clone_() const =0
Key key() const noexcept
The duplicate key that was attempted to be added.
deref_iterator find(Key j) const
virtual void deallocate_() const =0
Default allocator for list, map, and set types.
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.
static const KeyFormatter DefaultKeyFormatter
const std::type_info & storedTypeId() const
The typeid of the value stores in the Values.
internal::FastDefaultAllocator< typename std::pair< const Key, void * > >::type KeyValuePtrPairAllocator
const Value & value
The value.
const char * operation_
The operation that attempted to access the key.
ConstKeyValuePair operator*() const
const std::type_info & requestedTypeId() const
The requested typeid.
std::unique_ptr< ConstKeyValuePair > operator->()
M1<< 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12;Map< MatrixXf > M2(M1.data(), 6, 2)
~ValuesIncorrectType() noexcept override
~NoMatchFoundForFixed() noexcept override
bool operator!=(const deref_iterator &other) const
Array< double, 1, 3 > e(1./3., 0.5, 2.)
typename KeyValueMap::const_iterator const_iterator_type
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
std::map< Key, std::unique_ptr< Value >, std::less< Key >, std::allocator< std::pair< const Key, std::unique_ptr< Value > >> > KeyValueMap
double atDouble(size_t key) const
version for double
ValuesKeyAlreadyExists(Key key) noexcept
Construct with the key-value pair attempted to be added.
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.
const char * what() const noexcept override
std::vector< float > Values
~DynamicValuesMismatched() noexcept override
NoMatchFoundForFixed(size_t M1, size_t N1, size_t M2, size_t N2) noexcept
deref_iterator & operator++()
const std::type_info & requestedTypeId_
const Key key_
The key requested.
const std::type_info & storedTypeId_
static Value * allocate_clone(const Value &a)
bool operator==(const deref_iterator &other) const
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
deref_iterator upper_bound(Key j) const
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
void insertDouble(Key j, double c)
version for double
deref_iterator begin() const
deref_iterator end() const
An easy way to control which allocator is used for Fast* collections.
std::shared_ptr< Values > shared_ptr
A shared_ptr to this class.
~ValuesKeyAlreadyExists() noexcept override
std::uint64_t Key
Integer nonlinear key type.
ConstKeyValuePair(const KeyValuePair &kv)
Key key() const noexcept
The key that was attempted to be accessed that does not exist.
static bool filterHelper(const std::function< bool(Key)> filter, const ConstKeyValuePair &key_value)
const Key key_
The key that does not exist.
ConstKeyValuePair(Key _key, const Value &_value)