diff --git a/gtsam/nonlinear/Values-inl.h b/gtsam/nonlinear/Values-inl.h index 4ec584026..8337b82e2 100644 --- a/gtsam/nonlinear/Values-inl.h +++ b/gtsam/nonlinear/Values-inl.h @@ -109,174 +109,6 @@ namespace gtsam { return result; } -/* ************************************************************************* */ -#ifdef GTSAM_ALLOW_DEPRECATED_SINCE_V42 -#include - - template - class Values::Filtered { - public: - /** A key-value pair, with the value a specific derived Value type. */ - typedef _ValuesKeyValuePair KeyValuePair; - typedef _ValuesConstKeyValuePair ConstKeyValuePair; - typedef KeyValuePair value_type; - - typedef - boost::transform_iterator< - KeyValuePair(*)(Values::KeyValuePair), - boost::filter_iterator< - std::function, - Values::iterator> > - iterator; - - typedef iterator const_iterator; - - typedef - boost::transform_iterator< - ConstKeyValuePair(*)(Values::ConstKeyValuePair), - boost::filter_iterator< - std::function, - Values::const_iterator> > - const_const_iterator; - - iterator begin() { return begin_; } - iterator end() { return end_; } - const_iterator begin() const { return begin_; } - const_iterator end() const { return end_; } - const_const_iterator beginConst() const { return constBegin_; } - const_const_iterator endConst() const { return constEnd_; } - - /** Returns the number of values in this view */ - size_t size() const { - size_t i = 0; - for (const_const_iterator it = beginConst(); it != endConst(); ++it) - ++i; - return i; - } - - private: - Filtered( - const std::function& filter, - Values& values) : - begin_( - boost::make_transform_iterator( - boost::make_filter_iterator(filter, values.begin(), values.end()), - &ValuesCastHelper::cast)), end_( - boost::make_transform_iterator( - boost::make_filter_iterator(filter, values.end(), values.end()), - &ValuesCastHelper::cast)), constBegin_( - boost::make_transform_iterator( - boost::make_filter_iterator(filter, - ((const Values&) values).begin(), - ((const Values&) values).end()), - &ValuesCastHelper::cast)), constEnd_( - boost::make_transform_iterator( - boost::make_filter_iterator(filter, - ((const Values&) values).end(), - ((const Values&) values).end()), - &ValuesCastHelper::cast)) { - } - - friend class Values; - iterator begin_; - iterator end_; - const_const_iterator constBegin_; - const_const_iterator constEnd_; - }; - - template - class Values::ConstFiltered { - public: - /** A const key-value pair, with the value a specific derived Value type. */ - typedef _ValuesConstKeyValuePair KeyValuePair; - typedef KeyValuePair value_type; - - typedef typename Filtered::const_const_iterator iterator; - typedef typename Filtered::const_const_iterator const_iterator; - - /** Conversion from Filtered to ConstFiltered */ - ConstFiltered(const Filtered& rhs) : - begin_(rhs.beginConst()), - end_(rhs.endConst()) {} - - iterator begin() { return begin_; } - iterator end() { return end_; } - const_iterator begin() const { return begin_; } - const_iterator end() const { return end_; } - - /** Returns the number of values in this view */ - size_t size() const { - size_t i = 0; - for (const_iterator it = begin(); it != end(); ++it) - ++i; - return i; - } - - FastList keys() const { - FastList result; - for(const_iterator it = begin(); it != end(); ++it) - result.push_back(it->key); - return result; - } - - private: - friend class Values; - const_iterator begin_; - const_iterator end_; - ConstFiltered( - const std::function& filter, - const Values& values) { - // We remove the const from values to create a non-const Filtered - // view, then pull the const_iterators out of it. - const Filtered filtered(filter, const_cast(values)); - begin_ = filtered.beginConst(); - end_ = filtered.endConst(); - } - }; - - template - Values::Values(const Values::Filtered& view) { - for(const auto key_value: view) { - Key key = key_value.key; - insert(key, static_cast(key_value.value)); - } - } - - template - Values::Values(const Values::ConstFiltered& view) { - for(const auto key_value: view) { - Key key = key_value.key; - insert(key, static_cast(key_value.value)); - } - } - - Values::Filtered - inline Values::filter(const std::function& filterFcn) { - return filter(filterFcn); - } - - template - Values::Filtered - Values::filter(const std::function& filterFcn) { - return Filtered(std::bind(&filterHelper, filterFcn, - std::placeholders::_1), *this); - } - - Values::ConstFiltered - inline Values::filter(const std::function& filterFcn) const { - return filter(filterFcn); - } - - template - Values::ConstFiltered - Values::filter(const std::function& filterFcn) const { - return ConstFiltered(std::bind(&filterHelper, - filterFcn, std::placeholders::_1), *this); - } -#endif - /* ************************************************************************* */ template<> inline bool Values::filterHelper(const std::function filter, diff --git a/gtsam/nonlinear/Values.cpp b/gtsam/nonlinear/Values.cpp index c7321c904..7e2295b85 100644 --- a/gtsam/nonlinear/Values.cpp +++ b/gtsam/nonlinear/Values.cpp @@ -168,14 +168,6 @@ namespace gtsam { } } - /* ************************************************************************* */ -#ifdef GTSAM_ALLOW_DEPRECATED_SINCE_V42 - std::pair Values::tryInsert(Key j, const Value& value) { - std::pair result = values_.insert(j, value.clone_()); - return std::make_pair(boost::make_transform_iterator(result.first, &make_deref_pair), result.second); - } -#endif - /* ************************************************************************* */ void Values::update(Key j, const Value& val) { // Find the value to update diff --git a/gtsam/nonlinear/Values.h b/gtsam/nonlinear/Values.h index db107bcc7..d7043c7ff 100644 --- a/gtsam/nonlinear/Values.h +++ b/gtsam/nonlinear/Values.h @@ -30,10 +30,6 @@ #include #include #include -#ifdef GTSAM_ALLOW_DEPRECATED_SINCE_V42 -#include -#include -#endif #include #include @@ -301,103 +297,6 @@ namespace gtsam { std::map // , std::less, Eigen::aligned_allocator extract(const std::function& filterFcn = &_truePredicate) const; -#ifdef GTSAM_ALLOW_DEPRECATED_SINCE_V42 - // Types obtained by iterating - typedef KeyValueMap::const_iterator::value_type ConstKeyValuePtrPair; - typedef KeyValueMap::iterator::value_type KeyValuePtrPair; - - /// Mutable forward iterator, with value type KeyValuePair - typedef boost::transform_iterator< - std::function, KeyValueMap::iterator> iterator; - - /// Const forward iterator, with value type ConstKeyValuePair - typedef boost::transform_iterator< - std::function, KeyValueMap::const_iterator> const_iterator; - - /// Mutable reverse iterator, with value type KeyValuePair - typedef boost::transform_iterator< - std::function, KeyValueMap::reverse_iterator> reverse_iterator; - - /// Const reverse iterator, with value type ConstKeyValuePair - typedef boost::transform_iterator< - std::function, KeyValueMap::const_reverse_iterator> const_reverse_iterator; - - /** insert that mimics the STL map insert - if the value already exists, the map is not modified - * and an iterator to the existing value is returned, along with 'false'. If the value did not - * exist, it is inserted and an iterator pointing to the new element, along with 'true', is - * returned. */ - std::pair tryInsert(Key j, const Value& value); - - static ConstKeyValuePair make_const_deref_pair(const KeyValueMap::const_iterator::value_type& key_value) { - return ConstKeyValuePair(key_value.first, *key_value.second); } - - static KeyValuePair make_deref_pair(const KeyValueMap::iterator::value_type& key_value) { - return KeyValuePair(key_value.first, *key_value.second); } - - const_iterator begin() const { return boost::make_transform_iterator(values_.begin(), &make_const_deref_pair); } - const_iterator end() const { return boost::make_transform_iterator(values_.end(), &make_const_deref_pair); } - iterator begin() { return boost::make_transform_iterator(values_.begin(), &make_deref_pair); } - iterator end() { return boost::make_transform_iterator(values_.end(), &make_deref_pair); } - const_reverse_iterator rbegin() const { return boost::make_transform_iterator(values_.rbegin(), &make_const_deref_pair); } - const_reverse_iterator rend() const { return boost::make_transform_iterator(values_.rend(), &make_const_deref_pair); } - reverse_iterator rbegin() { return boost::make_transform_iterator(values_.rbegin(), &make_deref_pair); } - reverse_iterator rend() { return boost::make_transform_iterator(values_.rend(), &make_deref_pair); } - - /** Find an element by key, returning an iterator, or end() if the key was - * not found. */ - iterator find(Key j) { return boost::make_transform_iterator(values_.find(j), &make_deref_pair); } - - /** Find an element by key, returning an iterator, or end() if the key was - * not found. */ - const_iterator find(Key j) const { return boost::make_transform_iterator(values_.find(j), &make_const_deref_pair); } - - /** Find the element greater than or equal to the specified key. */ - iterator lower_bound(Key j) { return boost::make_transform_iterator(values_.lower_bound(j), &make_deref_pair); } - - /** Find the element greater than or equal to the specified key. */ - const_iterator lower_bound(Key j) const { return boost::make_transform_iterator(values_.lower_bound(j), &make_const_deref_pair); } - - /** Find the lowest-ordered element greater than the specified key. */ - iterator upper_bound(Key j) { return boost::make_transform_iterator(values_.upper_bound(j), &make_deref_pair); } - - /** Find the lowest-ordered element greater than the specified key. */ - const_iterator upper_bound(Key j) const { return boost::make_transform_iterator(values_.upper_bound(j), &make_const_deref_pair); } - - /** A filtered view of a Values, returned from Values::filter. */ - template - class Filtered; - - /** A filtered view of a const Values, returned from Values::filter. */ - template - class ConstFiltered; - - /** Constructor from a Filtered view copies out all values */ - template - Values(const Filtered& view); - - /** Constructor from a Filtered or ConstFiltered view */ - template - Values(const ConstFiltered& view); - - /// A filtered view of the original Values class. - Filtered GTSAM_DEPRECATED - filter(const std::function& filterFcn); - - /// A filtered view of the original Values class, also filter on type. - template - Filtered GTSAM_DEPRECATED - filter(const std::function& filterFcn = &_truePredicate); - - /// A filtered view of the original Values class, const version. - ConstFiltered GTSAM_DEPRECATED - filter(const std::function& filterFcn) const; - - /// A filtered view of the original Values class, also on type, const. - template - ConstFiltered GTSAM_DEPRECATED filter( - const std::function& filterFcn = &_truePredicate) const; -#endif - private: // Filters based on ValueType (if not Value) and also based on the user- // supplied \c filter function. diff --git a/gtsam/nonlinear/tests/testValues.cpp b/gtsam/nonlinear/tests/testValues.cpp index a738ecc1d..42e2d563c 100644 --- a/gtsam/nonlinear/tests/testValues.cpp +++ b/gtsam/nonlinear/tests/testValues.cpp @@ -199,25 +199,6 @@ TEST(Values, basic_functions) EXPECT(values.exists(4)); EXPECT(values.exists(6)); EXPECT(values.exists(8)); - -#ifdef GTSAM_ALLOW_DEPRECATED_SINCE_V42 - // find - const Values& values_c = values; - EXPECT_LONGS_EQUAL(4, values.find(4)->key); - EXPECT_LONGS_EQUAL(4, values_c.find(4)->key); - - // lower_bound - EXPECT_LONGS_EQUAL(4, values.lower_bound(4)->key); - EXPECT_LONGS_EQUAL(4, values_c.lower_bound(4)->key); - EXPECT_LONGS_EQUAL(4, values.lower_bound(3)->key); - EXPECT_LONGS_EQUAL(4, values_c.lower_bound(3)->key); - - // upper_bound - EXPECT_LONGS_EQUAL(6, values.upper_bound(4)->key); - EXPECT_LONGS_EQUAL(6, values_c.upper_bound(4)->key); - EXPECT_LONGS_EQUAL(4, values.upper_bound(3)->key); - EXPECT_LONGS_EQUAL(4, values_c.upper_bound(3)->key); -#endif } /* ************************************************************************* */