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

@@ -11,7 +11,7 @@ class Digraph : public Graph<T> {
public:
Digraph() = default;
Digraph(std::map<T, std::set<T>> G);
Digraph(std::unordered_map<T, std::unordered_set<T>> G);
// Return true if there is a path from u to v
bool contains(const T& u, const T& v);
@@ -27,7 +27,7 @@ public:
};
template<typename T>
Digraph<T>::Digraph(std::map<T, std::set<T>> G) {
Digraph<T>::Digraph(std::unordered_map<T, std::unordered_set<T>> G) {
this->adjList = G;
}
@@ -49,7 +49,7 @@ void Digraph<T>::remove(const T& u, const T& v) {
template<typename T>
auto Digraph<T>::reverse() {
std::map<T, std::set<T>> revMatrix;
std::unordered_map<T, std::unordered_set<T>> revMatrix;
for (const auto& u : this->vertices()) {
for (const auto& v : this->adjList[u]) {