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