From 3db0dce008ae1451f633d917a8e5627d0e9537aa Mon Sep 17 00:00:00 2001 From: Richard Roberts Date: Wed, 14 Aug 2013 19:24:57 +0000 Subject: [PATCH] Returning iterator from VectorValues::insert --- gtsam/linear/VectorValues.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/gtsam/linear/VectorValues.h b/gtsam/linear/VectorValues.h index 43cf1e9ad..66ab35ca2 100644 --- a/gtsam/linear/VectorValues.h +++ b/gtsam/linear/VectorValues.h @@ -174,21 +174,23 @@ namespace gtsam { * j is already used. * @param value The vector to be inserted. * @param j The index with which the value will be associated. */ - void insert(Key j, const Vector& value) { - insert(std::make_pair(j, value)); // Note only passing a reference to the Vector + iterator insert(Key j, const Vector& value) { + return insert(std::make_pair(j, value)); // Note only passing a reference to the Vector } /** Insert a vector \c value with key \c j. Throws an invalid_argument exception if the key \c * j is already used. * @param value The vector to be inserted. * @param j The index with which the value will be associated. */ - void insert(const std::pair& key_value) { + iterator insert(const std::pair& key_value) { // Note that here we accept a pair with a reference to the Vector, but the Vector is copied as // it is inserted into the values_ map. - if(!values_.insert(key_value).second) + std::pair result = values_.insert(key_value); + if(!result.second) throw std::invalid_argument( "Requested to insert variable '" + DefaultKeyFormatter(key_value.first) + "' already in this VectorValues."); + return result.first; } /** Insert all values from \c values. Throws an invalid_argument exception if any keys to be