Commit 672829be authored by Alessio Netti's avatar Alessio Netti
Browse files

Switching to std::unordered_map in MetadataStore and SensorNavigator

parent 0674d775
......@@ -29,7 +29,7 @@
#define PROJECT_METADATASTORE_H
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <boost/property_tree/ptree.hpp>
#include <boost/foreach.hpp>
......@@ -241,7 +241,7 @@ public:
*
* @return A string to Metadata_t map
*/
const map<string, SensorMetadata>& getMap() {
const unordered_map<string, SensorMetadata>& getMap() {
return _metadata;
}
......@@ -332,7 +332,7 @@ public:
protected:
map<string, SensorMetadata> _metadata;
unordered_map<string, SensorMetadata> _metadata;
};
......
......@@ -29,7 +29,7 @@
#define PROJECT_SENSORNAVIGATOR_H
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <boost/regex.hpp>
#include <limits.h>
......@@ -186,7 +186,7 @@ public:
* @param depth maximum depth of the desired subtree
* @return The internal map used to store the sensor tree (or subtree)
*/
map<string, Node> *getSubTree(const string& node="__root__", int depth=INT_MAX);
unordered_map<string, Node> *getSubTree(const string& node="__root__", int depth=INT_MAX);
/**
* @brief Returns all nodes in the sensor tree at a certain depth
......@@ -342,7 +342,7 @@ protected:
bool _isSensorNode(const Node& node) { return node.sensors.empty() && node.children.empty(); }
//Recursive internal algorithms used for their public counterparts
void _getSubTree(const string& node, map<string, Node> *m, int depth);
void _getSubTree(const string& node, unordered_map<string, Node> *m, int depth);
void _getNodes(const string& node, set<string> *vec, int depth);
void _getSensors(const string& node, set<string> *vec, int depth);
......@@ -351,7 +351,7 @@ protected:
//Depth of the sensor tree
int _treeDepth;
//Internal map used to store the sensor tree
map<string, Node> *_sensorTree;
unordered_map<string, Node> *_sensorTree;
//Vector of regular expression objects that define the sensor hierarchy
vector<boost::regex> *_hierarchy;
boost::cmatch _match;
......
......@@ -125,7 +125,7 @@ void SensorNavigator::buildTree(const vector<string> *hierarchy, const vector<st
}
_usingTopics = topics != NULL;
_sensorTree = new map<string, Node>();
_sensorTree = new unordered_map<string, Node>();
//We initialize the sensor tree by pushing the root supernode
Node rootNode = {-1, set<string>(), set<string>(), "", ""};
......@@ -148,7 +148,7 @@ void SensorNavigator::buildCassandraTree(const map<string, vector<string> > *tab
_hierarchy = NULL;
_usingTopics = false;
_sensorTree = new map<string, Node>();
_sensorTree = new unordered_map<string, Node>();
boost::regex ignoreReg(ignore);
......@@ -172,7 +172,7 @@ void SensorNavigator::buildCassandraTree(const map<string, vector<string> > *tab
}
}
map<string, SensorNavigator::Node> *SensorNavigator::getSubTree(const string& node, int depth) {
unordered_map<string, SensorNavigator::Node> *SensorNavigator::getSubTree(const string& node, int depth) {
if(!_sensorTree || !_sensorTree->count(node))
throw domain_error("SensorNavigator: node not found in tree!");
......@@ -180,7 +180,7 @@ map<string, SensorNavigator::Node> *SensorNavigator::getSubTree(const string& no
throw out_of_range("SensorNavigator: depth not valid for subtree query!");
//We start by picking the start node, then we call the recursive routine
map<string, SensorNavigator::Node> *m = new map<string, Node>();
unordered_map<string, SensorNavigator::Node> *m = new unordered_map<string, Node>();
m->insert(make_pair(node,_sensorTree->at(node)));
_getSubTree(node, m, depth);
return m;
......@@ -298,7 +298,7 @@ void SensorNavigator::_getSensors(const string& node, set<string> *vec, int dept
_getSensors(n, vec, depth-1);
}
void SensorNavigator::_getSubTree(const string& node, map<string, SensorNavigator::Node> *m, int depth) {
void SensorNavigator::_getSubTree(const string& node, unordered_map<string, SensorNavigator::Node> *m, int depth) {
if(!_sensorTree || !_sensorTree->count(node))
return;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment