Hunt down std::map::emplace candidates
parent
eeda8a7ff2
commit
0710091887
|
@ -50,7 +50,7 @@ class DSFMap {
|
|||
iterator it = entries_.find(key);
|
||||
// if key does not exist, create and return itself
|
||||
if (it == entries_.end()) {
|
||||
it = entries_.insert(std::make_pair(key, empty)).first;
|
||||
it = entries_.insert({key, empty}).first;
|
||||
it->second.parent_ = it;
|
||||
it->second.rank_ = 0;
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ public:
|
|||
}
|
||||
|
||||
/** Handy 'insert' function for Matlab wrapper */
|
||||
bool insert2(const KEY& key, const VALUE& val) { return Base::insert(std::make_pair(key, val)).second; }
|
||||
bool insert2(const KEY& key, const VALUE& val) { return Base::insert({key, val}).second; }
|
||||
|
||||
/** Handy 'exists' function */
|
||||
bool exists(const KEY& e) const { return this->find(e) != this->end(); }
|
||||
|
|
|
@ -222,10 +222,9 @@ size_t getTicTocID(const char *descriptionC) {
|
|||
static gtsam::FastMap<std::string, size_t> idMap;
|
||||
|
||||
// Retrieve or add this string
|
||||
gtsam::FastMap<std::string, size_t>::const_iterator it = idMap.find(
|
||||
description);
|
||||
auto it = idMap.find(description);
|
||||
if (it == idMap.end()) {
|
||||
it = idMap.insert(std::make_pair(description, nextId)).first;
|
||||
it = idMap.insert({description, nextId}).first;
|
||||
++nextId;
|
||||
}
|
||||
|
||||
|
|
|
@ -396,7 +396,7 @@ class CameraSet : public std::vector<CAMERA, Eigen::aligned_allocator<CAMERA>> {
|
|||
|
||||
FastMap<Key, size_t> KeySlotMap;
|
||||
for (size_t slot = 0; slot < allKeys.size(); slot++)
|
||||
KeySlotMap.insert(std::make_pair(allKeys[slot], slot));
|
||||
KeySlotMap.emplace(allKeys[slot], slot);
|
||||
|
||||
// Schur complement trick
|
||||
// G = F' * F - F' * E * P * E' * F
|
||||
|
|
|
@ -245,7 +245,7 @@ namespace gtsam {
|
|||
void BayesTree<CLIQUE>::fillNodesIndex(const sharedClique& subtree) {
|
||||
// Add each frontal variable of this root node
|
||||
for(const Key& j: subtree->conditional()->frontals()) {
|
||||
bool inserted = nodes_.insert(std::make_pair(j, subtree)).second;
|
||||
bool inserted = nodes_.insert({j, subtree}).second;
|
||||
assert(inserted); (void)inserted;
|
||||
}
|
||||
// Fill index for each child
|
||||
|
|
|
@ -210,7 +210,7 @@ struct EliminationData {
|
|||
// putting orphan subtrees in the index - they'll already be in the index of the ISAM2
|
||||
// object they're added to.
|
||||
for (const Key& j: myData.bayesTreeNode->conditional()->frontals())
|
||||
nodesIndex_.insert(std::make_pair(j, myData.bayesTreeNode));
|
||||
nodesIndex_.emplace(j, myData.bayesTreeNode);
|
||||
|
||||
// Store remaining factor in parent's gathered factors
|
||||
if (!eliminationResult.second->empty()) {
|
||||
|
|
|
@ -218,13 +218,13 @@ namespace gtsam {
|
|||
// Add roots in sorted order
|
||||
{
|
||||
FastMap<Key,sharedNode> keys;
|
||||
for(const sharedNode& root: this->roots_) { keys.insert(std::make_pair(root->key, root)); }
|
||||
for(const sharedNode& root: this->roots_) { keys.emplace(root->key, root); }
|
||||
typedef typename FastMap<Key,sharedNode>::value_type Key_Node;
|
||||
for(const Key_Node& key_node: keys) { stack1.push(key_node.second); }
|
||||
}
|
||||
{
|
||||
FastMap<Key,sharedNode> keys;
|
||||
for(const sharedNode& root: expected.roots_) { keys.insert(std::make_pair(root->key, root)); }
|
||||
for(const sharedNode& root: expected.roots_) { keys.emplace(root->key, root); }
|
||||
typedef typename FastMap<Key,sharedNode>::value_type Key_Node;
|
||||
for(const Key_Node& key_node: keys) { stack2.push(key_node.second); }
|
||||
}
|
||||
|
@ -258,13 +258,13 @@ namespace gtsam {
|
|||
// Add children in sorted order
|
||||
{
|
||||
FastMap<Key,sharedNode> keys;
|
||||
for(const sharedNode& node: node1->children) { keys.insert(std::make_pair(node->key, node)); }
|
||||
for(const sharedNode& node: node1->children) { keys.emplace(node->key, node); }
|
||||
typedef typename FastMap<Key,sharedNode>::value_type Key_Node;
|
||||
for(const Key_Node& key_node: keys) { stack1.push(key_node.second); }
|
||||
}
|
||||
{
|
||||
FastMap<Key,sharedNode> keys;
|
||||
for(const sharedNode& node: node2->children) { keys.insert(std::make_pair(node->key, node)); }
|
||||
for(const sharedNode& node: node2->children) { keys.emplace(node->key, node); }
|
||||
typedef typename FastMap<Key,sharedNode>::value_type Key_Node;
|
||||
for(const Key_Node& key_node: keys) { stack2.push(key_node.second); }
|
||||
}
|
||||
|
|
|
@ -109,8 +109,7 @@ VariableSlots::VariableSlots(const FG& factorGraph)
|
|||
// we're combining. Initially we put the max integer value in
|
||||
// the array entry for each factor that will indicate the factor
|
||||
// does not involve the variable.
|
||||
iterator thisVarSlots; bool inserted;
|
||||
std::tie(thisVarSlots, inserted) = this->insert(std::make_pair(involvedVariable, FastVector<size_t>()));
|
||||
auto [thisVarSlots, inserted] = this->insert({involvedVariable, FastVector<size_t>()});
|
||||
if(inserted)
|
||||
thisVarSlots->second.resize(factorGraph.nrFactors(), Empty);
|
||||
thisVarSlots->second[jointFactorPos] = factorVarSlot;
|
||||
|
|
|
@ -126,13 +126,13 @@ predecessorMap2Graph(const PredecessorMap<KEY>& p_map) {
|
|||
std::tie(child,parent) = child_parent;
|
||||
if (key2vertex.find(child) == key2vertex.end()) {
|
||||
v1 = add_vertex(child, g);
|
||||
key2vertex.insert(std::make_pair(child, v1));
|
||||
key2vertex.emplace(child, v1);
|
||||
} else
|
||||
v1 = key2vertex[child];
|
||||
|
||||
if (key2vertex.find(parent) == key2vertex.end()) {
|
||||
v2 = add_vertex(parent, g);
|
||||
key2vertex.insert(std::make_pair(parent, v2));
|
||||
key2vertex.emplace(parent, v2);
|
||||
} else
|
||||
v2 = key2vertex[parent];
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ namespace gtsam {
|
|||
public:
|
||||
/** convenience insert so we can pass ints for TypedSymbol keys */
|
||||
inline void insert(const KEY& key, const KEY& parent) {
|
||||
std::map<KEY, KEY>::insert(std::make_pair(key, parent));
|
||||
std::map<KEY, KEY>::emplace(key, parent);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace gtsam {
|
|||
#ifdef TBB_GREATER_EQUAL_2020
|
||||
values_.emplace(key, x.segment(j, n));
|
||||
#else
|
||||
values_.insert(std::make_pair(key, x.segment(j, n)));
|
||||
values_.insert({key, x.segment(j, n)});
|
||||
#endif
|
||||
j += n;
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ namespace gtsam {
|
|||
#ifdef TBB_GREATER_EQUAL_2020
|
||||
values_.emplace(v.key, x.segment(j, v.dimension));
|
||||
#else
|
||||
values_.insert(std::make_pair(v.key, x.segment(j, v.dimension)));
|
||||
values_.insert({v.key, x.segment(j, v.dimension)});
|
||||
#endif
|
||||
j += v.dimension;
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ namespace gtsam {
|
|||
#ifdef TBB_GREATER_EQUAL_2020
|
||||
result.values_.emplace(key, Vector::Zero(value.size()));
|
||||
#else
|
||||
result.values_.insert(std::make_pair(key, Vector::Zero(value.size())));
|
||||
result.values_.insert({key, Vector::Zero(value.size())});
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
@ -267,7 +267,7 @@ namespace gtsam {
|
|||
#ifdef TBB_GREATER_EQUAL_2020
|
||||
result.values_.emplace(j1->first, j1->second + j2->second);
|
||||
#else
|
||||
result.values_.insert(std::make_pair(j1->first, j1->second + j2->second));
|
||||
result.values_.insert({j1->first, j1->second + j2->second});
|
||||
#endif
|
||||
|
||||
return result;
|
||||
|
@ -329,7 +329,7 @@ namespace gtsam {
|
|||
#ifdef TBB_GREATER_EQUAL_2020
|
||||
result.values_.emplace(j1->first, j1->second - j2->second);
|
||||
#else
|
||||
result.values_.insert(std::make_pair(j1->first, j1->second - j2->second));
|
||||
result.values_.insert({j1->first, j1->second - j2->second});
|
||||
#endif
|
||||
|
||||
return result;
|
||||
|
@ -349,7 +349,7 @@ namespace gtsam {
|
|||
#ifdef TBB_GREATER_EQUAL_2020
|
||||
result.values_.emplace(key_v.first, a * key_v.second);
|
||||
#else
|
||||
result.values_.insert(std::make_pair(key_v.first, a * key_v.second));
|
||||
result.values_.insert({key_v.first, a * key_v.second});
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ namespace gtsam {
|
|||
public:
|
||||
typedef Values::iterator iterator; ///< Iterator over vector values
|
||||
typedef Values::const_iterator const_iterator; ///< Const iterator over vector values
|
||||
typedef std::shared_ptr<This> shared_ptr; ///< shared_ptr to this class
|
||||
typedef std::shared_ptr<This> shared_ptr; ///< shared_ptr to this class
|
||||
typedef Values::value_type value_type; ///< Typedef to pair<Key, Vector>
|
||||
typedef value_type KeyValuePair; ///< Typedef to pair<Key, Vector>
|
||||
typedef std::map<Key, size_t> Dims; ///< Keyed vector dimensions
|
||||
|
@ -186,7 +186,7 @@ namespace gtsam {
|
|||
#if ! defined(GTSAM_USE_TBB) || defined (TBB_GREATER_EQUAL_2020)
|
||||
return values_.emplace(std::piecewise_construct, std::forward_as_tuple(j), std::forward_as_tuple(args...));
|
||||
#else
|
||||
return values_.insert(std::make_pair(j, Vector(std::forward<Args>(args)...)));
|
||||
return values_.insert({j, Vector(std::forward<Args>(args)...)});
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -195,7 +195,7 @@ namespace gtsam {
|
|||
* @param value The vector to be inserted.
|
||||
* @param j The index with which the value will be associated. */
|
||||
iterator insert(Key j, const Vector& value) {
|
||||
return insert(std::make_pair(j, value));
|
||||
return insert({j, value});
|
||||
}
|
||||
|
||||
/** Insert all values from \c values. Throws an invalid_argument exception if any keys to be
|
||||
|
@ -210,7 +210,7 @@ namespace gtsam {
|
|||
#ifdef TBB_GREATER_EQUAL_2020
|
||||
return values_.emplace(j, value);
|
||||
#else
|
||||
return values_.insert(std::make_pair(j, value));
|
||||
return values_.insert({j, value});
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -321,7 +321,7 @@ void ISAM2::recalculateIncremental(const ISAM2UpdateParams& updateParams,
|
|||
const int group =
|
||||
result->observedKeys.size() < affectedFactorsVarIndex.size() ? 1 : 0;
|
||||
for (Key var : result->observedKeys)
|
||||
constraintGroups.insert(std::make_pair(var, group));
|
||||
constraintGroups.emplace(var, group);
|
||||
}
|
||||
|
||||
// Remove unaffected keys from the constraints
|
||||
|
|
Loading…
Reference in New Issue