Refactor: Replace std::map and std::set with unordered versions

This commit is contained in:
stefiosif
2022-10-12 17:26:11 +03:00
parent c525aeaa43
commit dc7fa93a6a
13 changed files with 44 additions and 41 deletions

View File

@@ -31,10 +31,10 @@ public:
void remove(const std::vector<std::pair<T, T>>& edges);
private:
// Transitive closure matrix, used to answer reachability queries in O(1)
std::map<T, std::map<T, bool>> TC;
std::unordered_map<T, std::unordered_map<T, bool>> TC;
// For each SCC, store a reachability tree created as a BFS tree
std::map<T, BreadthFirstTree<T>> RT;
std::unordered_map<T, BreadthFirstTree<T>> RT;
// For each SCC, store collections of incoming, outgoing and internal edges
struct Edges {
@@ -42,7 +42,7 @@ private:
std::set<std::pair<T, T>> inc;
std::set<std::pair<T, T>> out;
};
std::map<T, Edges> E;
std::unordered_map<T, Edges> E;
// Decremental maintenance of strongly connected components
RodittyZwick<T> rodittyZwick;
@@ -101,7 +101,7 @@ void Frigioni<T>::remove(const std::vector<std::pair<T, T>>& edges) {
Eext.push_back({ u, v });
}
std::map<T, std::stack<T>> H;
std::unordered_map<T, std::stack<T>> H;
for (const auto& [u, v] : Eint) {
this->G.remove(u, v);
rodittyZwick.remove(u, v);