Refactor: Replace std::map and std::set with unordered versions
This commit is contained in:
@@ -16,7 +16,7 @@ class Tarjan {
|
||||
public:
|
||||
Tarjan() = default;
|
||||
|
||||
Tarjan(std::map<T, std::set<T>> adjList) : adjList(adjList) {}
|
||||
Tarjan(std::unordered_map<T, std::unordered_set<T>> adjList) : adjList(adjList) {}
|
||||
|
||||
//
|
||||
auto execute();
|
||||
@@ -24,7 +24,7 @@ public:
|
||||
//
|
||||
void strongConnect(const T& u);
|
||||
private:
|
||||
std::map<T, std::set<T>> adjList;
|
||||
std::unordered_map<T, std::unordered_set<T>> adjList;
|
||||
std::stack<T> S;
|
||||
std::int16_t index = 0;
|
||||
std::vector<SCC<T>> SCCs;
|
||||
@@ -35,7 +35,7 @@ private:
|
||||
int lowlink = -1;
|
||||
bool onStack = false;
|
||||
};
|
||||
std::map<T, Vertex> vmap;
|
||||
std::unordered_map<T, Vertex> vmap;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
@@ -55,7 +55,7 @@ void Tarjan<T>::strongConnect(const T& u) {
|
||||
|
||||
// If u is a root node, pop the stack and generate an SCC
|
||||
if (vmap[u].lowlink == vmap[u].index) {
|
||||
std::map<T, std::set<T>> scc;
|
||||
std::unordered_map<T, std::unordered_set<T>> scc;
|
||||
bool finished = false;
|
||||
cid = S.top();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user